Deutsch English Français Italiano |
<20240912174404.730@kylheku.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Kaz Kylheku <643-408-1753@kylheku.com> Newsgroups: comp.lang.lisp Subject: Re: CAR/CDR vs FIRST/REST Date: Fri, 13 Sep 2024 00:47:57 -0000 (UTC) Organization: A noiseless patient Spider Lines: 32 Message-ID: <20240912174404.730@kylheku.com> References: <vbva6t$c0o9$1@dont-email.me> Injection-Date: Fri, 13 Sep 2024 02:47:58 +0200 (CEST) Injection-Info: dont-email.me; posting-host="99dc7076b0b49591e69cd20e1421cb3c"; logging-data="540159"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/51JhD79hY9UC+lR86Ke+5oOzR2ihreXA=" User-Agent: slrn/pre1.0.4-9 (Linux) Cancel-Lock: sha1:nzXut6ovCy+TzGFUduCVMoDRoec= Bytes: 1726 On 2024-09-12, B. Pym <Nobody447095@here-nor-there.org> wrote: > Barry Margolin wrote: > >> > (mapcan #'(lambda (x) (and (numberp x) (list x))) list) >> >> > (loop for x in list >> > when (numberp x) collect x) >> >> I agree with this example. Once I learned LOOP I never used the >> above idiom again. > > (filter number? '(a b c 1 2 3)) > ===> > (1 2 3) Also, once you realize that "remove-if-not" is "keep-if": (remove-if-not #'numberp list) then you also will not use the poor "idiom": (mapcan #'(lambda (x) (and (numberp x) (list x))) list) Not to mention that once you learn that (lambda ...) is a macro which writes #'(lambda ...) for you, you will tend not to use the latter again. -- TXR Programming Language: http://nongnu.org/txr Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal Mastodon: @Kazinator@mstdn.ca