Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #238: You did wha... oh _dear_....


comp / comp.lang.lisp / Re: CAR/CDR vs FIRST/REST

SubjectAuthor
* Re: CAR/CDR vs FIRST/RESTB. Pym
`- Re: CAR/CDR vs FIRST/RESTKaz Kylheku

1
Subject: Re: CAR/CDR vs FIRST/REST
From: B. Pym
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Tue, 2 Jul 2024 21:33 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: No_spamming@noWhere_7073.org (B. Pym)
Newsgroups: comp.lang.lisp
Subject: Re: CAR/CDR vs FIRST/REST
Date: Tue, 2 Jul 2024 21:33:23 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <v61rmv$1q5l1$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Tue, 02 Jul 2024 23:33:23 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="33dab6b85b955ed0102028bfe3f606d5";
logging-data="1906337"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19fkZwanB+yM/f6cteDh1YC"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:r0xmnBzGZejPqVIDE41DGgDRPHg=
View all headers

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)

Subject: Re: CAR/CDR vs FIRST/REST
From: Kaz Kylheku
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Tue, 2 Jul 2024 22:58 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 643-408-1753@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Re: CAR/CDR vs FIRST/REST
Date: Tue, 2 Jul 2024 22:58:00 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <20240702155524.692@kylheku.com>
References: <v61rmv$1q5l1$1@dont-email.me>
Injection-Date: Wed, 03 Jul 2024 00:58:00 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="30e244ac737476d78edd2cd6194d0a15";
logging-data="1933073"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/i6KzrDEGH7kiaRLDLbVs77NYQxlXLw0c="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:Axg+FEKq7jtfBLuzh+9Yf8pmqQo=
View all headers

On 2024-07-02, B. Pym <No_spamming@noWhere_7073.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)

In Common Lisp, filter has a funny name: remove-if-not.

(remove-if-not #'numberp '(a b c 1 2 3))
-->
(1 2 3)

Likely because of the funny name, the function is marked deprecated,
which is silly.

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

1

rocksolid light 0.9.8
clearnet tor