Re: When to use apply

Liste des GroupesRevenir à cl lisp 
Sujet : Re: When to use apply
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.lisp
Date : 17. Jun 2025, 19:30:07
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20250617112306.761@kylheku.com>
References : 1
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2025-06-17, B. Pym <Nobody447095@here-nor-there.org> wrote:
Of course, after going through all of that you then see why loop is so
handy:
 
CL-USER> (defun nth-elements (n &rest lists)
           (loop for item in lists collect (nth n item)))
 
NTH-ELEMENTS
CL-USER> (nth-elements 3 '(10 20 hello x world) '(-1 -2 -3 y) '(z0 z1 z2 z))
 
(X Y Z)
>
(define (nth-elements n . seqs)
  (map (lambda (xs) (list-ref xs n)) seqs))
>
(nth-elements 3
  '(10 20 hello x world)
  '(-1 -2 -3 y)
  '(z0 z1 z2 z))

1> (map 3 '((10 20 hello x world) (-1 -2 -3 y) (z0 z1 z2 z)))
(x y z)

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Date Sujet#  Auteur
17 Jun 25 * Re: When to use apply3B. Pym
17 Jun 25 +- Re: When to use apply1B. Pym
17 Jun 25 `- Re: When to use apply1Kaz Kylheku

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal