in reply to (Golf) Ordered Combinations
#!/usr/bin/perl sub c {my$n=-1+shift;$n?map{my$c=$_;map$c.$_,c($n,@_)}@_:@_}; sub d {my$n=shift;--$n?map{my$d=$_;map$d.$_,d($n,@_)}@_:@_}; print join " ", c qw(2 a b c); print "\n"; print join " ", d qw(2 a b c); print "\n"; print join " ", c qw(4 0 1); print "\n"; print join " ", d qw(4 0 1); print "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: (Golf) Ordered Combinations
by adolfoams@gmail.com (Initiate) on Aug 12, 2014 at 13:26 UTC | |
by AppleFritter (Vicar) on Aug 12, 2014 at 14:04 UTC |