[squeak-dev] Bad value for Random seed ?

Levente Uzonyi leves at elte.hu
Sun Sep 21 17:29:07 UTC 2014


I've uploaded a new version to the Inbox. which should solve the problems 
with Random. For this particular issue, you can use #hashSeed:

((1 to: 10000) collect: [:n | (Random basicNew hashSeed: n) nextInt: 10 ] as: Bag) sortedCounts.

gives

  {1007->10 . 1006->7 . 1004->1 . 1004->4 . 1004->8 . 1003->3 . 998->5 . 
995->6 . 992->9 . 987->2}

while

((1 to: 10000) collect: [:n | (Random basicNew seed: n) nextInt: 10 ] as: Bag) sortedCounts.

still gives

  {10000->1}


Levente

On Sun, 21 Sep 2014, Stéphane Rollandin wrote:

> Actually it looks like using smallish values for seed is a problem too:
>
> ((1 to: 1000) collect: [:n | (Random seed: 1000 atRandom) nextInt: 10]) asSet
>
> gives
>
> a Set(1)
>
>
> Stef
>
>


More information about the Squeak-dev mailing list