On Thu, Aug 14, 2008 at 12:15 PM, Patrick Perry <[EMAIL PROTECTED]> wrote:
> Actually, a much better solution is:
>
> variant :: Int -> Gen a -> Gen a
> variant v (Gen m) = Gen (\n r -> m n (rands r v))
>  where
>  rands r0 0 = r0
>  rands r0 n = let (r1,r2) = split r0
>                   (n',s)  = n `quotRem` 2
>               in case s of
>                    0 -> rands r1 n'
>                    _ -> rands r2 n'

It's not really clear to me how this works. Could you please explain?

Cheers,

Johan
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to