in reply to Is this a fair shuffle?

What is the current fascination with fair shuffles? Why not just use List::Util's shuffle()?

Replies are listed 'Best First'.
Re^2: Is this a fair shuffle?
by Roy Johnson (Monsignor) on Apr 01, 2005 at 04:21 UTC
    Sometimes it's about understanding how things work and relate, rather than just being handed a tool that is made for the job. In this case, I was thinking (rightly or wrongly) about how pretty much all array functions are combine or reduce operations. Then I thought about sorting and shuffling and thought that they were inverses of each other, operating on the order of an array, so it seemed like sort should work to shuffle. If it doesn't, I want to know why not, so that I can adjust my thinking accordingly.

    Plus, I think it would be cool to have a built-in for shuffling. It even reads well if you want to make a randomizing sub: sort randomly LIST.


    Caution: Contents may have been coded under pressure.
      if you put it in this mathematical inverse sense, i would say that since your imaginary function of random->sorted is not one-to-one, so it can not have an inverse (ie, every input:random array has exactly one output:sorted array, but the inverse one input:sorted array could have many output:random arrays).

      this is just for thinking's sake, it definitely doesn't give you any answer