newLISP Fan Club

Forum => Anything else we might add? => Topic started by: Dmi on July 31, 2005, 06:03:46 PM

Title: iteration filter
Post by: Dmi on July 31, 2005, 06:03:46 PM
Is there a way to simplify construction like such:
(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
(push (until (some-func)) db)
Or is there a way to write macro for such thing?

Or is it a wrong lispish style? ;-)
Title:
Post by: Fanda on August 14, 2005, 09:19:37 PM
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
Title:
Post by: Dmi on August 15, 2005, 12:54:33 AM
Hmm... nice view. I sometimes forgot that lisp is about lists.  :-)

Thanks!