]> Cypherpunks repositories - gostls13.git/commit
math/rand: remove noop iteration in Perm
authorJohan Euphrosine <proppy@google.com>
Sat, 1 Dec 2012 22:11:46 +0000 (14:11 -0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Sat, 1 Dec 2012 22:11:46 +0000 (14:11 -0800)
commitd7b0f2a524743fef990c6905e628304a0065116f
tree852c3efa71ea8f945931bc05354b576cbbf35087
parent444b7b53e02487e3292c9db04b584915a21de54b
math/rand: remove noop iteration in Perm

The first iteration always do `m[0], m[0] = m[0], m[0]`, because
`rand.Intn(1)` is 0.

fun note: IIRC in TAOCP version of this algorithm, `i` goes
backward (n-1->1), meaning that the "already" shuffled part of the
array is never altered betweens iterations, while in the current
implementation the "not-yet" shuffled part of the array is
conserved between iterations.

R=golang-dev
CC=golang-dev
https://golang.org/cl/6845121
src/pkg/math/rand/rand.go