Adrian Hey wrote:
AFAICT neilGobbler isn't even entirely safe as an implementation of
an eager take. There's nothing the Haskell standard to stop it being
transformed into..
neilGobbler :: Int -> [x] -> [x]
neilGobbler n xs = length (take n xs) `seq` take n xs
Whoops, I see stackGobbler has the same problem..
-- Strict version of take
stackGobbler :: Int -> [x] -> [x]
stackGobbler 0 _ = []
stackGobbler _ [] = []
stackGobbler n (x:xs) = let xs' = stackGobbler (n-1) xs
in xs' `seq` (x:xs')
I guess this is an example of the Haskell standard needing to be
tightened up a bit, but that is another story..
Regards
--
Adrian Hey
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe