I've just been investigating a performance oddity in using splitAt
on a long stream of random numbers. I don't understand why GHC
appears to want to traverse the first part of the list twice.

GHC seems to implement the splitAt function something like

splitAt n xs = (take n xs, drop n xs)

whereas Hugs is something like

splitAt n (x : xs) = (x : xs', xs'')
                where (xs', xs'') = splitAt (n-1) xs

which seems much more sensible to me. Wouldn't it be better to change
GHC to the Hugs method? Have I misunderstood something?


Richard.


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to