mirror of
https://github.com/samber/lo.git
synced 2026-04-22 23:47:11 +08:00
fa095e4b4f
* fix(doc): fix go playground demo URL * fix(doc): add more go playground demo URL
759 B
759 B
name, slug, sourceRef, category, subCategory, signatures, playUrl, variantHelpers, similarHelpers, position
| name | slug | sourceRef | category | subCategory | signatures | playUrl | variantHelpers | similarHelpers | position | ||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Shuffle | shuffle | it/seq.go#L357 | it | sequence |
|
https://go.dev/play/p/3WOx-ukGvKK |
|
|
130 |
Returns a sequence of shuffled values using Fisher-Yates algorithm. Note: this requires collecting all elements in memory.
Examples:
seq := func(yield func(int) bool) {
_ = yield(1)
_ = yield(2)
_ = yield(3)
_ = yield(4)
_ = yield(5)
}
shuffled := it.Shuffle(seq)
var result []int
for v := range shuffled {
result = append(result, v)
}
// result contains the same elements in random order