http://www.perlmonks.org?node_id=77981


in reply to Re: (Golf) Per Mutations
in thread (Golf) Per Mutations

Non-recursive, handles repeated elements?
sub permute{ @r=[];$e=$_,@r=map{@a=@$_;map{@b=@a;splice(@b,$_,0,$e);[@b]}0..@a}@r f +or@_;@r }
77 chars...

UPDATE
75...

sub permute{ @r=[];$e=$_,@r=map{@a=@$_;map[@a[0..$_-1],$e,@a[$_..$#a]],0..@a}@r for +@_;@r }