using less stack
Tue, 19 Mar 2002 11:15:28 +0000
Thanks for all the advice. In the end, I couldn't make $! work for me
(it always seems to be harder than I think it will be to use it, and $!
and deepSeq makes my code run slowly). But a continuation passing style
foldl worked wonderfully.
I now have:
> cpsfold f a  = a
> cpsfold f a (x:xs) = f x a (\y -> cpsfold f y xs)
and f takes a continuation, Bob's my uncle, and I have a program that
runs quickly in constant space!
Amanda Clare http://users.aber.ac.uk/ajc99/
Tel: +44 (0)1970 621787 Fax: +44 (0)1970 622455
Dept. of Computer Science, University of Wales, Aberystwyth, SY23 3DB