jeudi 22 juillet 2021

How can I select a random subsequence of length 'l' in Haskell?

I have a list of vertices [1..n] and I need to select a random subsequence of the vertices of length 'l'.

Eg : generateS 3 [5,6,7,8,9,10,11,12,13]

Answer = [5,11,13]

Is there any better way than:

sort (take 5 $ randomRs (70,100) (mkStdGen 3) :: [Int]  )



Aucun commentaire:

Enregistrer un commentaire