Deutsch   English   Français   Italiano  
<v9u8cp$2n5rr$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: "B. Pym" <Nobody447095@here-nor-there.org>
Newsgroups: comp.lang.lisp
Subject: Re: CL: Processing more than one element of a sequence at a time?
Date: Mon, 19 Aug 2024 01:50:18 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <v9u8cp$2n5rr$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Mon, 19 Aug 2024 03:50:18 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="73cb5f305d7564436335108f5e5d2005";
	logging-data="2856827"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18zI3KOiEnnDuQp9ZIVbV+R"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:5MXX0oW/3kA+mCiEUPgdHsLMTkY=
Bytes: 1502

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))