Skip to content

Commit

Permalink
save work
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrowder committed Jan 19, 2024
1 parent 15378c0 commit 3aa6c01
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- Make the default output for a single word be a
suitable word for an arg regex selection, e.g.,
abbrev "Args" => "A|Ar|Arg|Args"
+ Add info in the README
- Separate tests into one for each arg

2.1.0 2023-06-14T16:05:14-05:00
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ DESCRIPTION

**Abbreviations** is a module with one automatically exported subroutine, `abbreviations`, which takes as input a set of words and returns the original set with added unique abbreviations for the set. (Note the input words are also abbreviations in the context of this module.)

A natural consequence of generating all the abbreviations for a set of one word is this: the ouput provides the parts of a junction which matches any partial length of the target word. For example, given a target word 'Args':

use Abbreviations;
use Test;
my $target = "Args";
my $junction = abbrev $target; # OUTPUT: "A|Ar|Arg|Args";
my $res = False;
for @w {
when /$junction/ {
$res = True
}
default {
$res = False
}
}
is $res, True; # OUTPUT: ok 1

Its signature:

sub abbreviations($word-set, #= Str, List, or Hash (Set)
Expand Down
23 changes: 23 additions & 0 deletions docs/README.rakudoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,29 @@ returns the original set with added unique abbreviations for the set.
(Note the input words are also abbreviations in the context of this
module.)

A natural consequence of generating all the abbreviations for a
set of one word is this: the ouput
provides the parts of a junction which matches any
partial length of the target word. For example, given a target
word 'Args':

=begin code
use Abbreviations;
use Test;
my $target = "Args";
my $junction = abbrev $target; # OUTPUT: "A|Ar|Arg|Args";
my $res = False;
for @w {
when /$junction/ {
$res = True
}
default {
$res = False
}
}
is $res, True; # OUTPUT: ok 1
=end code

Its signature:

=begin code
Expand Down
13 changes: 12 additions & 1 deletion t/03-unusual-inputs.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use Abbreviations :ALL;

my $debug = 0;

plan 19;
plan 20;

# good input test data
my @in = <A ab Abcde>; # arbitrary input order
Expand Down Expand Up @@ -107,3 +107,14 @@ for @w {
}
is $res, False;

subtest {
# example in README
my $target = "Args";
my $junction = abbrev $target; # OUTPUT: "A|Ar|Arg|Args";
my $res = False;
for @w {
when /$junction/ { $res = True }
default { $res = False }
}
is $res, True, "README example"; # OUTPUT: ok 1
}

0 comments on commit 3aa6c01

Please sign in to comment.