diff options
Diffstat (limited to 'lib/Games')
-rw-r--r-- | lib/Games/Word/Wordlist.pm | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/Games/Word/Wordlist.pm b/lib/Games/Word/Wordlist.pm index 81f8a5b..396d4de 100644 --- a/lib/Games/Word/Wordlist.pm +++ b/lib/Games/Word/Wordlist.pm @@ -2,7 +2,7 @@ package Games::Word::Wordlist; use strict; use warnings; -use Games::Word qw/all_permutations/; +use Games::Word qw/all_permutations is_subpermutation/; use List::MoreUtils qw/uniq/; sub new { @@ -173,6 +173,17 @@ sub words_like { return @words; } +sub subwords_of { + my $self = shift; + my $string = shift; + + my @words = (); + $self->_each_word(sub { push @words, $_[0] + if is_subpermutation($_[0], $string)}); + + return @words; +} + =head1 NAME Games::Word::Wordlist - ??? |