How can I return multiple random elements from a List .
This question How to choose a random element from an array in Scala? refers to using :
import scala.util.Random
val A = Array("please", "help", "me")
Random.shuffle(A.toList).head
The mutable in me is thinking I could create a for loop and keep selecting the next random element (excluding the one already selected) and add that to a new List. Is there a more idiomatic/functional way to achieve this in Scala ?
Random.shuffle(A.toList).take(n)Random.shuffle(A.toIndexedSeq).take(n)is better.