# efficiency question

**Konst Sushenko
**
konsu@microsoft.com

*Fri, 8 Feb 2002 17:24:40 -0800*

(moved to haskell-caf=E9)
I ran Hal's code on my computer, and with test2 I get a stack overflow =
(so I had to use +RTS option for it to finish). test1 does not overflow =
stack (of standard size, I mean without +RTS). Which implies that test2 =
uses more stack space than test1. why would it use more stack if not =
because of laziness?
konst
>* -----Original Message-----
*>* From: Hal Daume III [mailto:hdaume@ISI.EDU]=20
*>* Sent: Friday, February 08, 2002 4:35 PM
*>* To: Jorge Adriano
*>* Cc: Konst Sushenko; haskell@haskell.org
*>* Subject: Re: efficiency question
*>*=20
*>*=20
*>* I agree that it's the overhead of (,), but I don't see why=20
*>* there would be
*>* any overhead for doing this.
*>*=20
*>* --
*>* Hal Daume III
*>*=20
*>* "Computer science is no more about computers | hdaume@isi.edu
*>* than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume
*>*=20
*>* On Sat, 9 Feb 2002, Jorge Adriano wrote:
*>*=20
*>* > On Friday 08 February 2002 23:52, Hal Daume III wrote:
*>* > > I've tried using a strict fold:
*>* > >
*>* > > foldl' f a [] =3D a
*>* > > foldl' f a (x:xs) =3D (foldl' f $! f a x) xs
*>* > >
*>* > > but that has no effect (or minimal effect).
*>* >=20
*>* > That wouldn't work even if if laziness is the problem=20
*>* because that would only=20
*>* > cause the elements of the list to be evaluated to head=20
*>* normal form, the=20
*>* > elements of the pair would not be evaluated so you'd have a=20
*>* 'suspension of =20
*>* > (minus and plus) operations'.
*>* >=20
*>* > instead of=20
*>* > > (\x (a,b) -> (x+a,x-b))
*>* > try=20
*>* > > (\x (a,b) -> (((,) $! x-a)$! x-b) )
*>* >=20
*>* > I just noticed that you were the one who sent me the DeepSeq module.
*>* > This is the kind of place where I want to use it.
*>* > Instead of $!, try $!!.
*>* >=20
*>* >=20
*>* > And Konst Sushenko wrote:
*>* > >>My guess is that it is due to the laziness of the=20
*>* addition/subtraction
*>* > >>in (,)
*>* >=20
*>* > Seems to me like lazyness is not the right guess because=20
*>* both functions Hall=20
*>* > first posted were lazy. So I think it's just the overhead=20
*>* of applying (,)=20
*>* > besides (+) and (-) in each step. Do I make sense or am I=20
*>* missing something?
*>* >=20
*>* > J.A.
*>* >=20
*>*=20
*>*=20
*