Page 1 of 1

iteration filter

Posted: Mon Aug 01, 2005 1:03 am
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? ;-)

Posted: Mon Aug 15, 2005 4:19 am
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

Posted: Mon Aug 15, 2005 7:54 am
by Dmi
Hmm... nice view. I sometimes forgot that lisp is about lists. :-)
Thanks!