Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #308: CD-ROM server needs recalibration


comp / comp.lang.lisp / Re: Returning no value

SubjectAuthor
o Re: Returning no valueB. Pym

1
Subject: Re: Returning no value
From: B. Pym
Newsgroups: comp.lang.lisp, comp.lang.scheme
Organization: A noiseless patient Spider
Date: Fri, 30 Aug 2024 09:13 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Nobody447095@here-nor-there.org (B. Pym)
Newsgroups: comp.lang.lisp,comp.lang.scheme
Subject: Re: Returning no value
Date: Fri, 30 Aug 2024 09:13:19 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <vas2fe$ebqd$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Fri, 30 Aug 2024 11:13:20 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="abfbf0e8d1f6a5c18d0eb734601f646f";
logging-data="470861"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19BPvoIVHNa+NBqCQe1uda2"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:GVGR43bE/dX+Lp2rY0iQZ8Z8yUo=
View all headers

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)

1

rocksolid light 0.9.8
clearnet tor