iteration filter

For the Compleat Fan
Locked
Dmi
Posts: 408
Joined: Sat Jun 04, 2005 4:16 pm
Location: Russia
Contact:

iteration filter

Post by Dmi »

Is there a way to simplify construction like such:

Code: Select all

(push
  (let (s nil)
    (until (set 's (some-func)))
    s)
  db)
(push ... db) - is only envelope for example: say, I want to repeatedly got values and push only non-nil ones.

Is there a standard way to do that? Something like

Code: Select all

(push (until (some-func)) db)
Or is there a way to write macro for such thing?
Or is it a wrong lispish style? ;-)
WBR, Dmi

Fanda
Posts: 253
Joined: Tue Aug 02, 2005 6:40 am
Contact:

Post by Fanda »

I was just thinking...

Would it work for you?
1) iterate through the (some-func) and save the results to 'results
2) use command (filter) on 'results to get only non-nil ones
3) push the good ones into your list

Fanda

Dmi
Posts: 408
Joined: Sat Jun 04, 2005 4:16 pm
Location: Russia
Contact:

Post by Dmi »

Hmm... nice view. I sometimes forgot that lisp is about lists. :-)
Thanks!
WBR, Dmi

Locked