Re: CAR/CDR vs FIRST/REST

Liste des GroupesRevenir à cl lisp 
Sujet : Re: CAR/CDR vs FIRST/REST
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.lisp
Date : 13. Sep 2024, 02:47:57
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240912174404.730@kylheku.com>
References : 1
User-Agent : slrn/pre1.0.4-9 (Linux)
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

Date Sujet#  Auteur
12 Sep 24 * Re: CAR/CDR vs FIRST/REST2B. Pym
13 Sep 24 `- Re: CAR/CDR vs FIRST/REST1Kaz Kylheku

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal