forked from hoelzro/p6-algorithm-lcs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial stab at integrating in Raku Community Modules
- Loading branch information
Showing
13 changed files
with
423 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Linux | ||
|
||
on: | ||
push: | ||
branches: | ||
- '*' | ||
tags-ignore: | ||
- '*' | ||
pull_request: | ||
|
||
jobs: | ||
raku: | ||
strategy: | ||
matrix: | ||
os: | ||
- ubuntu-latest | ||
raku-version: | ||
- 'latest' | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: Raku/setup-raku@v1 | ||
with: | ||
raku-version: ${{ matrix.raku-version }} | ||
- name: Run Special Tests | ||
run: raku run-tests -i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: MacOS | ||
|
||
on: | ||
push: | ||
branches: | ||
- '*' | ||
tags-ignore: | ||
- '*' | ||
pull_request: | ||
|
||
jobs: | ||
raku: | ||
strategy: | ||
matrix: | ||
os: | ||
- macos-latest | ||
raku-version: | ||
- 'latest' | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: Raku/setup-raku@v1 | ||
with: | ||
raku-version: ${{ matrix.raku-version }} | ||
- name: Run Special Tests | ||
run: raku run-tests -i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Windows | ||
|
||
on: | ||
push: | ||
branches: | ||
- '*' | ||
tags-ignore: | ||
- '*' | ||
pull_request: | ||
|
||
jobs: | ||
raku: | ||
strategy: | ||
matrix: | ||
os: | ||
- windows-latest | ||
raku-version: | ||
- 'latest' | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: Raku/setup-raku@v1 | ||
with: | ||
raku-version: ${{ matrix.raku-version }} | ||
- name: Run Special Tests | ||
run: raku run-tests -i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.precomp/ | ||
/Algorithm-LCS-* |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Revision history for Algorithm::LCS | ||
|
||
{{$NEXT}} | ||
- Initial version as a Raku Community Module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,28 @@ | ||
{ | ||
"perl": "6.*", | ||
"name": "Algorithm::LCS", | ||
"license" : "MIT", | ||
"version": "0.1.0", | ||
"description": "Implementation of the longest common subsequence algorithm", | ||
"author": "Rob Hoelz", | ||
"depends": [], | ||
"provides" : { | ||
"Algorithm::LCS" : "lib/Algorithm/LCS.pm" | ||
}, | ||
"source-url": "git://github.com/hoelzro/p6-algorithm-lcs.git" | ||
"auth": "zef:raku-community-modules", | ||
"authors": [ | ||
"Rob Hoelz", | ||
"Raku Community" | ||
], | ||
"build-depends": [ | ||
], | ||
"depends": [ | ||
], | ||
"description": "Implementation of the longest common subsequence algorithm", | ||
"license": "MIT", | ||
"name": "Algorithm::LCS", | ||
"perl": "6.*", | ||
"provides": { | ||
"Algorithm::LCS": "lib/Algorithm/LCS.rakumod" | ||
}, | ||
"resources": [ | ||
], | ||
"source-url": "https://github.com/hoelzro/p6-algorithm-lcs.git", | ||
"tags": [ | ||
"ALGORITHM", | ||
"LCS" | ||
], | ||
"test-depends": [ | ||
], | ||
"version": "0.1.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,91 @@ | ||
# TITLE | ||
[![Actions Status](https://github.com/hoelzro/p6-algorithm-lcs/actions/workflows/linux.yml/badge.svg)](https://github.com/hoelzro/p6-algorithm-lcs/actions) [![Actions Status](https://github.com/hoelzro/p6-algorithm-lcs/actions/workflows/macos.yml/badge.svg)](https://github.com/hoelzro/p6-algorithm-lcs/actions) [![Actions Status](https://github.com/hoelzro/p6-algorithm-lcs/actions/workflows/windows.yml/badge.svg)](https://github.com/hoelzro/p6-algorithm-lcs/actions) | ||
|
||
Algorithm::LCS | ||
NAME | ||
==== | ||
|
||
# SYNOPSIS | ||
Algorithm::LCS - Implementation of the longest common subsequence algorithm | ||
|
||
```perl6 | ||
use Algorithm::LCS; | ||
SYNOPSIS | ||
======== | ||
|
||
# regular usage | ||
say lcs(<A B C D E F G>, <A C F H J>); # prints T<A C F> | ||
```raku | ||
use Algorithm::LCS; | ||
|
||
# custom comparator via :compare | ||
say lcs(<A B C>, <D C F>, :compare(&infix:<eq>)); | ||
# regular usage | ||
say lcs(<A B C D E F G>, <A C F H J>); # prints T<A C F> | ||
|
||
# extra special custom comparison via :compare-i | ||
my @a = slurp('one.txt'); | ||
my @b = slurp('two.txt'); | ||
my @a-hashed = @a.map({ hash-algorithm($_) }); | ||
my @b-hashed = @b.map({ hash-algorithm($_) }); | ||
say lcs(@a, @b, :compare-i({ @a-hashed[$^i] eqv @b-hashed[$^j] })); | ||
# custom comparator via :compare | ||
say lcs(<A B C>, <D C F>, :compare(&infix:<eq>)); | ||
|
||
# extra special custom comparison via :compare-i | ||
my @a = slurp('one.txt'); | ||
my @b = slurp('two.txt'); | ||
my @a-hashed = @a.map({ hash-algorithm($_) }); | ||
my @b-hashed = @b.map({ hash-algorithm($_) }); | ||
say lcs(@a, @b, :compare-i({ @a-hashed[$^i] eqv @b-hashed[$^j] })); | ||
``` | ||
|
||
DESCRIPTION | ||
=========== | ||
|
||
This module contains a single subroutine, `lcs`, that calculates the longest common subsequence between two sequences of data. `lcs` takes two lists as required parameters; you may also specify the comparison function (which defaults to `eqv`) via the `&compare` named parameter). | ||
|
||
Sometimes you may want to maintain a parallel array of information to consult during calculation (for example, if you're comparing long lines of a file, and you'd like a speedup by comparing their hashes rather than their contents); for that, you may use the `&compare-i` named argumeny | ||
|
||
SUBROUTINES | ||
=========== | ||
|
||
### sub lcs | ||
|
||
```raku | ||
sub lcs( | ||
@a, | ||
@b, | ||
:&compare = Code.new, | ||
:&compare-i is copy | ||
) returns Mu | ||
``` | ||
|
||
# DESCRIPTION | ||
Returns the longest common subsequence of two sequences of data. | ||
|
||
class Mu $ | ||
---------- | ||
|
||
The first sequence | ||
|
||
class Mu $ | ||
---------- | ||
|
||
The second sequence | ||
|
||
class Mu $ | ||
---------- | ||
|
||
The comparison function (defaults to C<eqv>) | ||
|
||
class Mu $ | ||
---------- | ||
|
||
The compare-by-index function (defaults to using &compare) | ||
|
||
SEE ALSO | ||
======== | ||
|
||
[Wikipedia article](http://en.wikipedia.org/wiki/Longest_common_subsequence_problem) | ||
|
||
AUTHORS | ||
======= | ||
|
||
* Rob Hoelz | ||
|
||
* Raku Community | ||
|
||
COPYRIGHT AND LICENSE | ||
===================== | ||
|
||
Copyright (c) 2014 - 2017 Rob Hoelz | ||
|
||
This module contains a single subroutine, lcs, that calculates the longest common subsequence between two sequences of data. lcs takes two lists as required parameters; you may also specify the comparison function (which defaults to eqv) via the &compare named parameter). Sometimes you may want to maintain a parallel array of information to consult during calculation (for example, if you're comparing long lines of a file, and you'd like a speedup by comparing their hashes rather than their contents); for that, you may use the &compare-i named parameter. | ||
Copyright (c) 2024 Raku Community | ||
|
||
# SEE ALSO | ||
This library is free software; you can redistribute it and/or modify it under the MIT license. | ||
|
||
http://en.wikipedia.org/wiki/Longest_common_subsequence_problem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name = Algorithm::LCS | ||
|
||
[ReadmeFromPod] | ||
filename = lib/Algorithm/LCS.rakumod | ||
|
||
[UploadToZef] | ||
|
||
[Badges] | ||
provider = github-actions/linux.yml | ||
provider = github-actions/macos.yml | ||
provider = github-actions/windows.yml |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.