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

Re: Collect-if?

30 views
Skip to first unread message

WJ

unread,
Nov 16, 2012, 5:51:17 AM11/16/12
to
Friedrich Dominicus wrote:

> Thaddeus L Olczyk <olc...@interaccess.com> writes:
>
> > Is there a statement somthing like collect-if in the loop construct?
> >
> > For example:
> > (loop x in list
> > collect-if (not (= (property x) 0))
> > (process x))
>
> (defun test-it (liste)
> (loop for item in liste
> when (>= item 0) collect item into result
> finally (return result)))


* (remove-if #'minusp '(-3 0 -2 4))
(0 4)


Clojure:

user=> (remove neg? '(-3 0 -2 4))
(0 4)

Racket:

> (filter-not negative? '(-3 0 -2 4))
'(0 4)

WJ

unread,
Jan 2, 2015, 6:12:21 PM1/2/15
to
WJ wrote:

> Friedrich Dominicus wrote:
>
> > Thaddeus L Olczyk <olc...@interaccess.com> writes:
> >
> > > Is there a statement somthing like collect-if in the loop construct?
> > >
> > > For example:
> > > (loop x in list
> > > collect-if (not (= (property x) 0))
> > > (process x))
> >
> > (defun test-it (liste)
> > (loop for item in liste
> > when (>= item 0) collect item into result
> > finally (return result)))
>
>
> * (remove-if #'minusp '(-3 0 -2 4))
> (0 4)

Gauche Scheme:

gosh> (remove negative? '(-3 0 -2 4))
(0 4)
0 new messages