On Fri, 4 Dec 1998, Keith Wansbrough wrote:

> Surely it would be better to split the one stream into several infinite ones:
> 
>   splitStream :: [a] -> ([a],[a])
> 
>   splitStream xs = unzip (spl xs)
>     where spl (x:y:xs) = (x,y):(spl xs)
> 
> Then you don't have to know how many you are going to use from each stream.

Closer inspection reveals this is not a necessarily a the best idea
(particularly if you're going to repeat the trick several times on various
subsets) because you can get nasty correlations between the various
streams even from quite a good random number generator. There was a paper
published in the JFP about a better way of splitting streams which I think
appeared sometime between January 1996--October 1996. (Sorry I can't be
more specific -- I didn't really keep any notes on all the
frantic background reading I was doing :-) )

___cheers,_dave_________________________________________________________
email: [EMAIL PROTECTED]       "I'm guilty of a lot of things but I've
www.cs.bris.ac.uk/~tweed/pi.htm   never violated the law of conservation
work tel: (0117) 954-5253         of energy!" -- Bart Kosko, Nanotime



Reply via email to