Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Algorithm help

by Anonymous Monk
on Jan 09, 2001 at 22:34 UTC ( #50728=note: print w/ replies, xml ) Need Help??


in reply to Algorithm help
in thread Search Algorithm

@fruit=qw(apples oranges pears); for $f0 (@fruit){ for $f1( "",@fruit ){ print "$f0$f1\n" unless $f0 eq $f1; }}


Comment on Re: Algorithm help
Re: Re: Algorithm help
by eg (Friar) on Jan 09, 2001 at 23:26 UTC

    Here's the same thing, except using nested maps. Is there a way to do this in just one pass?

    my @fruit = qw/ apples oranges pears /; my @salad = mix_up( @fruit ); print join(', ', @salad), "\n"; sub mix_up { return map { my $tmp=$_; map { $tmp eq $_ ? $_ : "$tmp$_" } @_; } +@_; }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (12)
As of 2014-09-30 19:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (381 votes), past polls