From e21e901ef097173279efd2d9e357f97235a91451 Mon Sep 17 00:00:00 2001 From: David Eisinger Date: Sun, 16 Jul 2023 22:12:21 -0400 Subject: [PATCH] math/rand --- content/notes/golang/index.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/content/notes/golang/index.md b/content/notes/golang/index.md index 7262404..a9c134f 100644 --- a/content/notes/golang/index.md +++ b/content/notes/golang/index.md @@ -132,6 +132,10 @@ I find [Go][1] really compelling, even though it's not super applicable to my jo * Go has anonymous functions (`func` w/o name) * Slices * Use `append` to add to a slice; this creates a new slice, so you have to capture the return value (`s = append(s, 100)`) +* `math/rand` + * `rand.Intn`: random integer between 0 and the specified int + * `rand.Float64`: random float between 0.0. and 1.0 + * `rand.Shuffle`: randomize an array/slice; takes a length and a swap function [17]: https://stackoverflow.com/a/40951013 [18]: https://go.dev/doc/effective_go#named-results