Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Just for fun, here a poor mans shuffle:

DB<228> sort { (-1)**(rand(2)%2) } 1..10 => (5, 8, 7, 6, 9, 10, 1, 4, 2, 3)

Surely neither efficient, nor well mixed and pretty pointless since List::Util is core. =)

Cheers Rolf

( addicted to the Perl Programming Language)

update

for completeness:

> nor well mixed

The distribution is perfect iff the list has 2^n elements

DB<483> for (1..100000) {$x=0;$g[$x++]{$_}++ for sort {(-1) ** int r +and 2} a..d } => "" DB<484> \@g => [ { a => 25302, b => 25028, c => 24852, d => 24818 }, { a => 25062, b => 24925, c => 24773, d => 25240 }, { a => 24773, b => 24944, c => 25203, d => 25080 }, { a => 24863, b => 25103, c => 25172, d => 24862 }, ]

In reply to poor man's shuffle :) by LanX
in thread Curious find while comparing grep, map, and smart match... by dbuckhal

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (10)
    As of 2014-11-26 20:56 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My preferred Perl binaries come from:














      Results (173 votes), past polls