Skip to content

Commit

Permalink
Initial stab at integrating in Raku Community Modules
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Aug 9, 2024
1 parent 602dae1 commit 59183ca
Show file tree
Hide file tree
Showing 13 changed files with 423 additions and 170 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/linux.yml
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
26 changes: 26 additions & 0 deletions .github/workflows/macos.yml
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
26 changes: 26 additions & 0 deletions .github/workflows/windows.yml
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.precomp/
/Algorithm-LCS-*
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

4 changes: 4 additions & 0 deletions Changes
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
37 changes: 26 additions & 11 deletions META6.json
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"
}
99 changes: 80 additions & 19 deletions README.md
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
11 changes: 11 additions & 0 deletions dist.ini
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
128 changes: 0 additions & 128 deletions lib/Algorithm/LCS.pm

This file was deleted.

Loading

0 comments on commit 59183ca

Please sign in to comment.