Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Re: Algorithm help

by eg (Friar)
on Jan 09, 2001 at 23:26 UTC ( #50738=note: print w/replies, xml ) Need Help??

in reply to Re: Algorithm help
in thread Search Algorithm

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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://50738]
[Corion]: erix: Yes, but that's mostly for skipping characters you'll never read, but this approach skips the problem of needing to load more data while looking at a half-match
[Corion]: I mostly wonder how I can add this "reversal" to my toolchest, and if it's worth it or just clever
[choroba]: It should greatly simplify the parsing code, no flags or additional reading of the next buffer needed
[Corion]: choroba: Yeah, that's why I like that approach; it seems even quite obvious in retrospect to me, but many things are in hindsight ;)

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (13)
As of 2016-12-06 15:36 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (109 votes). Check out past polls.