dimanche 23 octobre 2016

Shuffle some sequence of List in Scala

I'm using scala.util.Random, then I know how to shuffle a list. It's very useful to randomize an order inside Array list, for example:

val List(a, b, c, d) = Random.shuffle(List(1,2,3,4))
it will result

a = 1
b = 3
c = 2
d = 4

the result of a, b, c, d could be any random value between 1 to 4. But the thing is we can't do this:

val a:List = List(1,2,Random.shuffle(3,4,5))

please share if you guys have any clue for this case. If no, please explain why.

Thanks!




Aucun commentaire:

Enregistrer un commentaire