Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re (tilly) 2: (Golf) Per Mutations

by tilly (Archbishop)
on May 04, 2001 at 19:16 UTC ( [id://77981]=note: print w/replies, xml ) Need Help??


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 }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (7)
As of 2024-04-18 14:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found