Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

.Re: Loop macro

10 views
Skip to first unread message

Robert L.

unread,
Mar 29, 2022, 7:37:03 PM3/29/22
to
Chris Riesbeck wrote:

> LOOP ... COLLECT vs. MAPCAR -- LAMBDA is a tie for me,
> but if you want to collect only certain values, then
>
> (loop for x in l
> when <test x>
> collect x)
>
> is hands-down clearer than
>
> (mapcan #'(lambda (x)
> (when <test x> (list x)))
> l)
>
> while
>
> (remove-if-not #'(lambda (x) <test x>) l)

Those who think that they know Loop actually know nothing
at all.

* (remove-if-not (lambda (n) (oddp n)) '(0 3 4 5 7))

(3 5 7)


* (remove-if-not 'oddp '(0 3 4 5 7))

(3 5 7)

>
> is OK but that double-negative leaves me cold.

Gauche Scheme:

(filter odd? (liota 22))
===>
(1 3 5 7 9 11 13 15 17 19 21)
0 new messages