Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Sorting file names randomly
- X-seq: zsh-users 12219
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxxxxx>
- Subject: Re: Sorting file names randomly
- Date: Mon, 19 Nov 2007 00:57:18 -0800
- In-reply-to: <20071119042136.GA11967@xxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20050723194240.GA32416@DervishD> <20050723212657.GA744@DervishD> <1050724064415.ZM20425@xxxxxxxxxxxxxxxxxxxxxxx> <20071119042136.GA11967@xxxxxxxxxxx>
On Nov 18, 11:21pm, Clint Adams wrote:
} Subject: Re: Sorting file names randomly
}
} On Sun, Jul 24, 2005 at 06:44:15AM +0000, Bart Schaefer wrote:
} > for ((i=1; i <= $#; ++i)) { h[$i.$RANDOM]=$argv[i] }
}
} Is there any chance that prepending "$i." and hashing it will
} decrease the randomness of the shuffle significantly?
I no longer remember why I didn't just use h[$RANDOM] -- it may have
been a typo. Looking back at the part of my message that you trimmed,
I said:
: The local RANDOM is there to force it to be zero-padded to 5 places,
: so all the hash keys are the same length; probably not essential.
But $i is not padded, so if that's prepended the hash keys aren't all
the same length any more, which is why I wonder whether it's meant to
be there at all.
However, I suspect the randomness might be reduced for large numbers
of arguments whether or not $i is prepended, because within each hash
bucket the values are in a list in the order they were added to that
bucket.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author