Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Re: Re^2: When the Best Solution Isn't

by diotalevi (Canon)
on Sep 23, 2002 at 13:18 UTC ( #200086=note: print w/replies, xml ) Need Help??


in reply to Re: Re^2: When the Best Solution Isn't
in thread When the Best Solution Isn't

There was a recent thread on the ActiveState list which was never quite solved. In general it came down to assigning to @_ was causing some weirdness to occur and ActiveState perl 5.6.1 would slow down to a crawl after a few thousand iterations. Other perls like my OpenBSD 5.6.1 and Cygwin 5.8.0 behaved nicely.

I'm not sure what the issue was but there may be lurking bug in assigning to @_. I'm warning against it. (or at least be aware so if you do run into trouble later...)

Update: fixed some spelling

  • Comment on Re: Re: Re^2: When the Best Solution Isn't

Replies are listed 'Best First'.
Re: Re: Re: Re^2: When the Best Solution Isn't
by japhy (Canon) on Sep 23, 2002 at 14:12 UTC
    Don't fret -- an equally speedy solution is thus:
    sub shuffle (\@) { my $d = shift; my @r = map rand, 0 .. $#$d; @$d[sort { $r[$a] <=> $r[$b] } 0 .. $#$d] = @$d; }
    It requires you send it an actual array, of course, but it is just as fast.

    _____________________________________________________
    Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (11)
As of 2019-11-12 16:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (66 votes). Check out past polls.

    Notices?