You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just found this package and think its great, thanks.
However Shuffle() returns always the same sequence.
Below is my test code.
I also included a shuffle of my own.
package main
import (
"fmt"
"github.com/feyeleanor/slices"
)
var is slices.ISlice
func main() {
is.Append(4)
is.Append(3)
is.Append(1)
is.Append(2)
is.Append(3)
slices.Sort(is)
slices.Shuffle(is)
fmt.Println(is)
}
import (
"math/rand"
"time"
)
func init() {
rand.Seed(time.Now().UTC().UnixNano())
}
// Shuffles the string
func Shuffle(s string) string {
l := len(s)
b := []byte(s)
for i := len(b) - 1; i != 0; i-- {
r := rand.Intn(l)
b[i], b[r] = b[r], b[i]
}
return string(b)
}
The text was updated successfully, but these errors were encountered:
Just found this package and think its great, thanks.
However Shuffle() returns always the same sequence.
Below is my test code.
I also included a shuffle of my own.
The text was updated successfully, but these errors were encountered: