Stack overflow on words (repeat 'a')
Hi With the expression: words (repeat 'a') Using WinHugs Sep 06 I get a stack overflow. Using Hugs Linux May 06 I get a GC fails to reclaim sufficient space error Using GHC and Yhc both of these succeed. I have a similar issue in one of my functions which is showing the same behaviour. Thanks Neil
With the expression: words (repeat 'a')
Using WinHugs Sep 06 I get a stack overflow.
Using Hugs Linux May 06 I get a GC fails to reclaim sufficient space error
Using GHC and Yhc both of these succeed.
I have a similar issue in one of my functions which is showing the same behaviour.
assuming you've got a terminating application in mind,-) a slightly more interesting expression is: test span = span (/=' ') $ replicate 100000 'a' ++ [' '] without optimizations, hugs is prone to fail for such deep applications of non-tail-recursive functions like span/break, splitAt, .. try this variation: span p l = span' p l id where span' p [] = \c->c ([],[]) span' p xs@(x:xs') | p x = span' p xs' . (\c (a,b)->c (x:a,b)) | otherwise = \c->c ([],xs) claus
i should have mentioned that Prelude.span is less strict, so: span p l = span' p l id where span' p [] = \c->c ([],[]) span' p xs@(x:xs') | p x = span' p xs' . (\c (a,b)->c (x:a,b)) | otherwise = \c->c ([],xs) -- Prelude.span fails, span succeeds test1 span = span (/=' ') $ replicate 1000000 'a' ++ [' '] test2 span = span (/=' ') $ take 1000000 (cycle "abc") ++ [' '] -- Prelude.span succeeds, span fails test3 span = take 1000000 $ fst $ span (/=' ') $ repeat 'a' claus
participants (2)
-
Claus Reinke -
Neil Mitchell