🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.functional
Article #239

Re: Laziness and Back-to-front Lists

#239
From: Tim Lambert
Date: Wed, 30 May 1990 12:49
33 lines
1939 bytes
In article <BJORNL.90Jul28100843@tarpon.tds.kth.se> 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
Technical Details
Message-ID: <LAMBERT.90May30224949@nankeen.spectrum.cs.unsw.oz.au>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!samsung!munnari.oz.au!metro!usage.csd.unsw.oz.au!usage.csd!lambert
References: <BJORNL.90May29165842@pike.tds.kth.se> <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.90Jul28100843@tarpon.

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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: <LAMBERT.90May30224949@nankeen.spectrum.cs.unsw.oz.au>
Date: 30 May 90 12:49:48 GMT
References: <BJORNL.90May29165842@pike.tds.kth.se> <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.90Jul28100843@tarpon.
Sender: news@usage.csd.unsw.oz.au
Organization: none
Lines: 33
In-reply-to: bjornl@tds.kth.se's message of 28 Jul 90 08:08:43 GMT