> On Mon, 22 Dec 2014, Ted Unangst wrote:
>
> > I would like to generate a permutation of some lines. We have random,
> > which is vageuly similar. This adds a -p option to instead permute
> > instead of randomly select.
>
> > + for (j = numlines; j > 1; j--) {
> > + size_t s = arc4random_uniform(j);
> > + char *tmp = array[s];
> > + array[s] = array[j - 1];
> > + array[j - 1] = tmp;
> > + }
>
> You could use the "forward" Knuth shuffle like that used in ip_id.c to
> perform the permutation while the lines are being read and avoid the
> extra pass.
>
> Some people have said that this is "less random" than the traditional
> backwards shuffle, but none have ever provided an argument why and I
> couldn't see how they differ myself.
Amusing :-)
Anyways, let's look back in time to when this really was "less random".
revision 1.5
date: 1997/10/01 19:06:30; author: kstailey; state: Exp; lines: +6 -8;
use arc4random
1997. How far we've come. And I wonder what this looks like in the
other BSD's and MacOS -- today.
Anyone want to place some bets? I'm thirsty! Actually, none of you
can bring a beer to me fast enough, so let's just look at one:
https://svnweb.freebsd.org/base/head/games/random/random.c?revision=209157&view=markup#l161
Yes, I know this isn't a serious program. But if you look at the
other enhancements they endeavoured to make, it is indicative.