From Newsgroup: comp.lang.scheme
Ken Tilton wrote:
Steven M. Haflich wrote:
I think the OP may be looking for something like this:
cl-user(10): (defun foo()
(let ((x (random 10)))
(and (< 5 x) x)))
foo
cl-user(11): (loop repeat 10
as x = (foo)
when x collect x) ; <<<<<
(6 8 9)
Sweet. But not wnat someone already offered?:
(loop repeat 10
when (foo)
collect it)
Gauche Scheme
(define (foo) (let1 x (random-integer 10) (and (< 5 x) x)))
(define (tcollect func tries)
(if (zero? tries)
'()
(append (cond ((func) => list) (#t '()))
(tcollect func (- tries 1)))))
(tcollect foo 10)
(9 8 9 6 7 9)
(tcollect + 3)
(0 0 0)
--- Synchronet 3.22a-Linux NewsLink 1.2