Re: CL: Processing more than one element of a sequence at a time?

Liste des GroupesRevenir à cl lisp 
Sujet : Re: CL: Processing more than one element of a sequence at a time?
De : Nobody447095 (at) *nospam* here-nor-there.org (B. Pym)
Groupes : comp.lang.lisp
Date : 19. Aug 2024, 03:50:18
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v9u8cp$2n5rr$1@dont-email.me>
User-Agent : XanaNews/1.18.1.6
Frode V. Fjeld wrote:

Raffaele Ricciardi <rfflrccrd@gmail.com> writes:
 
in CL, is there an idiomatic way to process more than one element of a
sequence at a time?
 
Yes: (loop for (a b) on list by #'cddr collect (cons a b))
 
Or without LOOP, I'd do:
 
  (do ((a (pop list) (pop list))
       (b (pop list) (pop list))
       (result nil))
      ((null list) (reverse result))
    (push (cons a b) result))

newLISP

(apply
  (fn (result a b) (push (cons a b) result -1))
  (cons '() '(f 3  g 4  h 5))
  3  ;; How many items to process at a time.
)

((f 3) (g 4) (h 5))

Date Sujet#  Auteur
19 Aug 24 o Re: CL: Processing more than one element of a sequence at a time?1B. Pym

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal