in reply to Combinatorics
use Data::Dumper; my @my_array = (1..7); my $my_sub_array_length = 4; print Dumper(combinations($my_sub_array_length, @my_array)); sub combinations { my($len,@a)=@_; return map{ my $c=$_<<1; [grep{($c>>=1)&1}@a]} &{sub{ my @ret = (); my $x; for($_=(1<<shift)-1; ($x=$_)<1<<$_[0]; $x&=~$x>>1,$x&=-$x,$_+=$x--,($x&=$_)?($_-=$x,$_+=$x/($ +x&-$x)):0 ){ push @ret,$_ } @ret; }}($len,0+@a); } [download]
Eureka! Give me a lever long enough ... Eppur si muove Mr. Watson – Come here – I want you Mary had a little lamb That's one small step for a man ... SCE to AUX I think I'll stop here
Results (270 votes). Check out past polls.