
22 Mar
2016
22 Mar
'16
7:38 a.m.
On 22-Mar-2016 4:14 pm, "Olumide" <50295@web.de> wrote:
randoms' :: (RandomGen g, Random a) => g -> [a] randoms' gen = let (value, newGen) = random gen in value:randoms' newGen
"random gen" returns a pair, whose first element is a random value, and the second element is a new generator. The cons (:) operator takes two values, one is an element, and the other is a list. It returns a new list with the provided arguments as head and tail. Ultimately, randoms' gen returns a list whose first element is a random value, and the rest of the list is the result of calling randoms' on the newly produced generator. Recursively, it generates an infinite lazy list of random elements. Hope this helps :) Regards, Sumit