[plt-scheme] Checking to see if a key is present in a hash table

From: Robby Findler (robby at cs.uchicago.edu)
Date: Sat Feb 25 18:51:26 EST 2006

At Sat, 25 Feb 2006 15:46:10 -0800, Gregory Woodhouse wrote:
> 
> On Feb 25, 2006, at 3:40 PM, Jens Axel Søgaard wrote:
> 
> >
> > Am I missing something, why not just
> >
> > (define (bound? t s)
> >   (hash-table-get t s (lambda () #f)))
> >
> > ?
> 
> I knew the failure thunk would be called, but I didn't know that the  
> value it returned would be returned as the value of hash-table-get.

That only works if the hash table doesn't bind the key to #f.

Robby


Posted on the users mailing list.