Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!prls!pyramid!hplabs!hplabsc!dsmith From: dsmith@hplabsc.UUCP (David Smith) Newsgroups: net.ai,net.lang.lisp Subject: Re: Common LISP style standards. Message-ID: <265@hplabsc.UUCP> Date: Mon, 2-Jun-86 13:10:26 EDT Article-I.D.: hplabsc.265 Posted: Mon Jun 2 13:10:26 1986 Date-Received: Wed, 4-Jun-86 06:37:03 EDT References: <2784@jhunix.UUCP> <3787@utah-cs.UUCP> <545@bcsaic.UUCP> Distribution: net Organization: Hewlett Packard Labs, Palo Alto CA Lines: 31 Xref: linus net.ai:3266 net.lang.lisp:766 > In article <3787@utah-cs.UUCP> shebs@utah-cs.UUCP (Stanley Shebs) writes: > >Sequence functions and mapping functions are generally preferable to > >handwritten loops, ... > > I'm in a little different boat, since we're using Franz rather than Common > Lisp, so perhaps the issues are a bit different ... > A common situation we find ourselves in is the following. We have a long list, > and we wish to apply some test to each member of the list. However, at some > point in the list, if the test returns a certain value, there is no need to > look further: we can jump out of processing the list right there, and thus > save time. ... > > Mike Maxwell CMU incorporated functions of CMUlisp into Franz, and these are apparently shipped with Franz: at least, on my computer, they are in /usr/src/ucb/lisp/lisplib/cmufncs.l. One of these functions is the function some. (some 'mylist 'func1 'func2) returns the first tail of mylist for which func1 of its car returns a non-nil value. Otherwise nil is returned. Successive tails of mylist are obtained by repeated application of func2 (usually cdr, or nil, which implies cdr). A nice cover macro for this is "exists". Example: (exists i '(2 5 3 8 4 1) (> i 6)) returns (8 4 1). David Smith HP Labs