Navin Rustagi <[email protected]> writes:

> It gives the error ERROR - Control stack overflow. I assume it is
> because of the lazy evaluation. 

Yes, you're just building a tower of additions, and when evaluating
this, you blow up the stack.  You need to make sure to evaluate the
tuple element each time, so instead of 

>    case ys of  'A'  -> (elf, els+1,elr,ell,elx) 

write:

>    case ys of  'A'  -> els `seq` (elf, els+1,elr,ell,elx)

(Strictly speaking this will only evaluate the previous value, but your
 tower of additions will now have maximum one floor)

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to