Path: utzoo!attcan!uunet!samsung!munnari.oz.au!metro!usage.csd.unsw.oz.au!usage.csd!lambert From: lambert@spectrum.eecs.unsw.oz (Tim Lambert) Newsgroups: comp.lang.functional Subject: Re: Laziness and Back-to-front Lists Message-ID: Date: 30 May 90 12:49:48 GMT References: <14531@dime.cs.umass.edu> <2535@skye.ed.ac.uk> <8691@cs.utexas.edu> <4170@castle.ed.ac.uk> <3738@moondance.cs.uq.oz.au> <4289@castle.ed.ac.uk> <1990May29.234840.29162@comp.vuw.ac.nz> bjornl@tds.kth.se (Bj|rn Lisper) writes: % For instance, if(b,x,y) defined by % % b => if(b,x,y) = x % not b => if(b,x,y) = y % % is a (non-strict) function in three arguments. Left-to-right lazy evaulation % will give the ordinary "conditional" semantics. As I pointed out, there are % cases where other evaluation orders terminate whereas this doesn't. If you want a different evaluation order you can define it (in Miranda) like this: > if b x x = x > if True x y = x > if False x y = y Now if is strict in its second and third arguments but not its first one. % Of course. A more interesting example is multiplication, that strictly % speaking (sic!) is non-strict, since whenever one argument returns zero the % other argument is not needed. if f(x) is non-terminating, then 0*f(x) still % terminates (and returns zero) if '*' is treated as a non-strict function % with left-to-right evaluation order. Is '*' usually implemented as a strict % or as a non-strict operator in lazy functional languages? Strict, since if you don't like this you can easily roll your own: > 0 $times y = 0 > x $times y = x*y Tim