
29 Dec
2006
29 Dec
'06
8:14 p.m.
Hello,
breakUp s | L.null s = [] | otherwise = h:(breakUp r) where (h,r) = L.splitAt 72 s
Running this on the 2G file blows up the stack pretty quickly, taking the first 1 million records (there are 20M of them) with a big stack parameter gives about 25% productivity, with GC taking the other 75%.
My understanding is that while this looks tail recursive, it isn't really because of laziness. I've tried throwing seq operators around, but they don't seem to do much to help the efficiency.
The function is not tail-recursive as written (you're returning h:breakUp r) but that shouldn't be a problem because of lazy evaluation. Can you give more context, particularly what happens to the result of breakUp? -Jeff