Re: Randomly outputting an array



In article <1152899358.709256.89380@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
ryanarossi@xxxxxxxxx says...
What would be the simplest way to output an array in random order, but
every element in the array MUST be outputted and the elements cannot
repeat? My current code is below, which I simply have a very large
array and I am outputting windows of an arbitary length.

Swap every element in the array with a random element of the array (may
include itself, in which case no actual swap is needed).

This will still work if you do it in stages, e.g. do it for the first
five elements, then remove them.

- Gerry Quinn


.



Relevant Pages

  • Re: Appending text files
    ... I am outputting ... The first file contains header ... The array can contain one or more filenames. ... I probably would have declared your Sub this way instead ...
    (microsoft.public.vb.general.discussion)
  • Re: similar Perl data structure?
    ... You don't even need to store the lines in an array in Perl, ... lines in memory before outputting. ... resources on the net, again, check the C FAQ, Question 18.9. ...
    (comp.lang.c)
  • Re: similar Perl data structure?
    ... strings in a file like: ... As far as I can tell, the OP doesn't explicitly require storing the lines in memory before outputting. ... For some recommended resources on the net, again, check the C FAQ, Question 18.9. ... Well he did mention he stored the string in an array, so I assumed he needs to store them. ...
    (comp.lang.c)
  • Re: Randomly outputting an array
    ... array and I am outputting windows of an arbitary length. ... DIM DECKAS INTEGER ... REM Display in original order ...
    (comp.programming)
  • Re: puts from #!, but with data structure chrome
    ... find it rather disappointing that outputting an array or hash does not ... but I'm testing stuff too cumbersome for IRB. ... Use p instead of puts. ...
    (comp.lang.ruby)