in reply to Subphrases from a phrase
Using Math::Combinatorics:
use warnings; use strict; use Math::Combinatorics; use Data::Dumper; my $phrase = 'camel perl book'; my @data = split /\s/, $phrase; my @sets; foreach my $count (1..@data) { my $combinat = Math::Combinatorics->new( count => $count, data => [@data] ); while(my @combo = $combinat->next_combination()) { push @sets, join ' ', @combo; } } print Dumper \@sets;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Subphrases from a phrase
by ikegami (Patriarch) on Aug 10, 2005 at 02:55 UTC |