[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Re: Map routines

William James

4/13/2015 3:07:00 PM

Bill Atkins wrote:

> > This seems like a simple question, but....
> >
> > Is there way of exiting a map routine (such as MAPHASH) once you've
> > found the value to want. I don't
> > necessarily want to use RETURN-FROM because I want to stay in the
> > function the map is in. I'm using
> > SBCL.
> >
> > Bill
>
> (block foo
> (maphash (lambda (x)
> (when (... x)
> (return-from foo x)))
> hash))

Gauche Scheme:

(use gauche.generator)

(define htable (alist->hash-table '((a 2)(b 3)(c 4))))

(generator-find
(lambda (x) (eq? 'b (car x)))
(x->generator htable))

===>
(b 3)