
10 Dec
2004
10 Dec
'04
10:06 a.m.
I'm missing something, a functional idiom, whatever. I know there's "length" to count the elements in a list and it works fine, but the function below stack overflows on a large list. countLines [] = 0 countLines (_:ls) = 1 + countLines ls I would have thought that this was tail recursive and would be flattened into iteration by the compiler. Can anyone explain why? Is it because the call is embedded in an expression? And additionally, how can I predict when the flattening will occur? Thanks, Will