But this is not really what it does. You can see from the output of
this code https://play.golang.org/p/88Llo7zHTeK

```
package main

import (
"fmt"
"math/rand"
)

func main() {
rand.Shuffle(10, func(i, j int) {
fmt.Println(i, j)
})
}
```

That `i` is not sampled from a random distribution, but in fact counts
down from the last index.

This is an implementation of the Fisher-Yates shuffle https://golang.or
g/src/math/rand/rand.go?s=7456:7506#L225

The reason that rand.Shuffle is called Shuffle is that that is it's
intention. Just as sort.Sort has the intention of sorting things, but
needn't necessarily (https://play.golang.org/p/VdMuiFfcp6w).

If we want to get metaphysical, nothing that we get the machine todo
intrinsically means anything beyond what meaning we ascribe to it
(under some transformation or set of bases). This is why we name things
and why those names matter.

On Tue, 2018-10-16 at 08:49 +1000, Neil Higgins wrote:
> So as well as getting rid of the euphemistic name, the documentation
> should simply say that it delivers n pairs of random numbers in the
> relevant range to a user-defined function.
>
> Neil Higgins (iPhone)
> higgins-dem...@bigpond.com
>
> >
> > On 16 Oct 2018, at 8:31 am, Neil Higgins <1955ne...@gmail.com>
> > wrote:
> >
> > Well, ok. But I would call “Shuffle” a misleading misnomer, because
> > until the user defines a shuffler function (which perversely might
> > not, or might fail to, shuffle anything), it does not shuffle
> > anything.
> >
> > Thanks for taking the time to answer my question. Neil

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to