Isn't this tail recursive?
Jyrinx
jyrinx_list@mindspring.com
11 Mar 2002 21:33:01 -0800
> > Normal -> countAll' cs 0 nl (nw + newWord) (nc + 1)
> > White -> countAll' cs 1 nl nw (nc + 1)
> > Newline -> countAll' cs 1 (nl + 1) nw (nc + 1)
>
>
> make this something like
>
> ...
>
> Normal -> nw' `seq` nc' `seq` countAll' cs 0 nl nw' nc'
> White -> nc' `seq` countAll' cs 1 nl nw nc'
> Newline-> nl' `seq` nc` `seq` countAll' cs 1 nl' nw nc'
> where nw' = nw + newWord
> nc' = nc + 1
> nl' = nl + 1
Cool! That did the trick ... (runs on very little memory *and* time now
... very cool) I've read through the other responses (thanks all!), and
I'm still not exactly sure what's going on ... I'm relatively new to
Haskell, and my understanding of laziness is hardly rigorous; in
general, how should I know where I need to use seq, and what I need to
use it on? Is there a paper I should read? (I've got Hudak's book, but
it does everything lazily IIRC)
Jyrinx
jyrinx_list@mindspring.com