Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Look again!

Update: Maybe this will clarify things a little?

#! perl -sw use strict; sub shuffl (\@) { my $r=pop; for (0..$#{$r}) { my $size = scalar @{$r}; my $choices = $size - $_; printf 'iteration: %2d Size: %2d rand(%2d) range: %2d .. % +2d %s', $_, $size, $choices, $_, $cho +ices + $_, $/; $a = $_ + rand @{$r} - $_; @$r[$_, $a] = @$r[$a, $_]; } } my @array = (1 ..15); shuffl @array; __END__ C:\test>210557 iteration: 0 Size: 15 rand(15) range: 0 .. 15 iteration: 1 Size: 15 rand(14) range: 1 .. 15 iteration: 2 Size: 15 rand(13) range: 2 .. 15 iteration: 3 Size: 15 rand(12) range: 3 .. 15 iteration: 4 Size: 15 rand(11) range: 4 .. 15 iteration: 5 Size: 15 rand(10) range: 5 .. 15 iteration: 6 Size: 15 rand( 9) range: 6 .. 15 iteration: 7 Size: 15 rand( 8) range: 7 .. 15 iteration: 8 Size: 15 rand( 7) range: 8 .. 15 iteration: 9 Size: 15 rand( 6) range: 9 .. 15 iteration: 10 Size: 15 rand( 5) range: 10 .. 15 iteration: 11 Size: 15 rand( 4) range: 11 .. 15 iteration: 12 Size: 15 rand( 3) range: 12 .. 15 iteration: 13 Size: 15 rand( 2) range: 13 .. 15 iteration: 14 Size: 15 rand( 1) range: 14 .. 15 C:\test>

Nah! You're thinking of Simon Templar, originally played (on UKTV) by Roger Moore and later by Ian Ogilvy

In reply to Re: Re: Re: Re: Re: random elements from array - new twist by BrowserUk
in thread random elements from array - new twist by felwick

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-04-19 16:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found