Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: possible combinations in sequence

by QM (Parson)
on Jun 13, 2006 at 23:40 UTC ( #555138=note: print w/replies, xml ) Need Help??


in reply to possible combinations in sequence

And for completeness, the glob solution, which spends more code fixing up the output than actually generating the results:
sub qm { my ($glob) = @_; my @rv; $glob =~ s/(\w+)/{$1,}/g; for my $combo (glob($glob)) { $combo =~ s/^:+//; next unless length($combo); push @rv, join ':', split /:+/, $combo; } return @rv; }
and is horribly slow as well.

BTW, it's interesting to note the change in benchmark results when the input is a long list of null strings:

$source = ':'x20;

-QM
--
Quantum Mechanics: The dreams stuff is made of

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://555138]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2020-11-01 00:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (291 votes). Check out past polls.

    Notices?