Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

You will not be elected to public office this year.


comp / comp.lang.lisp / Re: CL: Processing more than one element of a sequence at a time?

SubjectAuthor
o Re: CL: Processing more than one element of a sequence at a time?B. Pym

1
Subject: Re: CL: Processing more than one element of a sequence at a time?
From: B. Pym
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Mon, 19 Aug 2024 01:50 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Nobody447095@here-nor-there.org (B. Pym)
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=
View all headers

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

1

rocksolid light 0.9.8
clearnet tor