
5 Sep
2008
5 Sep
'08
12:54 p.m.
I am already using the following function pickOne xs g = (xs !! r, g') where (r, g') = Random.randomR (0, length xs - 1) g but I need to weight the items in the list, e.g. [(0.1, 'a') , (0.9, 'b')] for stochastic selection in a purely functional way, i.e. no monads. Any ideas welcome. Tim.