Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!harvard!husc6!panda!genrad!decvax!decwrl!glacier!kestrel!king From: king@kestrel.UUCP Newsgroups: net.ai,net.lang.lisp Subject: Re: Common LISP style standards. Message-ID: <8760@kestrel.ARPA> Date: Tue, 3-Jun-86 15:41:30 EDT Article-I.D.: kestrel.8760 Posted: Tue Jun 3 15:41:30 1986 Date-Received: Thu, 5-Jun-86 19:25:09 EDT Organization: Kestrel Institute, Palo Alto, CA Lines: 42 Xref: linus net.ai:3275 net.lang.lisp:771 From: michaelm@bcsaic.UUCP (michael maxwell) Newsgroups: net.ai,net.lang.lisp Date: 15 May 86 17:42:18 GMT Reply-To: michaelm@bcsaic.UUCP (michael maxwell) Distribution: net . . . 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. Now you can jump out of a do loop with "(return )", but you can't jump out of a mapc (mapcar etc.) with "return." So we wind up using "do" a lot of places where it would otherwise be natural to use "mapcar". I suppose I could use "catch" and "throw", but that looks so much like "goto" that I feel sinful if I use that solution... Any style suggestions? I'm way behind in this group, so I apologize in advance if you have seen this solution or a better one before. You might try (prog () (mapcar #'(lambda (y) (when (you-like y) (return (result-for y)))) x))) I tried it, and it works. It doesn't seem dirty to me, and it should be efficient. Even if the return point of a prog is such that it forces the lexical closure to be non-vacuous, this shouldn't be a problem when compiled. -- Mike Maxwell Boeing Artificial Intelligence Center ...uw-beaver!uw-june!bcsaic!michaelm -dick