On 2024-09-12, B. Pym <
Nobody447095@here-nor-there.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)
Also, once you realize that "remove-if-not" is "keep-if":
(remove-if-not #'numberp list)
then you also will not use the poor "idiom":
(mapcan #'(lambda (x) (and (numberp x) (list x))) list)
Not to mention that once you learn that (lambda ...) is
a macro which writes #'(lambda ...) for you, you will tend
not to use the latter again.
--
TXR Programming Language:
http://nongnu.org/txr
Cygnal: Cygwin Native Application Library:
http://kylheku.com/cygnal
Mastodon: @
Kazinator@mstdn.ca
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)