WJ wrote:
> Frode Vatvedt Fjeld wrote:
>
> > (defun confirm-loaded (n-val)
> > "Scan the current contents of data and confirm whether or not n-val
> > already exists."
> > (let ((match-key nil))
> > (prog
> > (maphash #'(lambda (k v)
> > (when (equalp n-val v)
> > (setf match-key k)
> > (go done)))
> > data)
> > done)
> > match-key))
>
> Gauche Scheme:
>
> (use gauche.generator :only (x->generator))
>
> (define (hash-table-val-exists? ht val)
> (generator-find
> (lambda (k.v) (equal? val (cdr k.v)))
> (x->generator ht)))
The problem is to find the key corresponding to a value
without scanning the entire hash-table.
MatzLisp (Ruby):
h = { "a" => 100, "b" => 200, "c" => 300, "d" => 300 }
h.key(200) #=> "b"
h.key(300) #=> "c"
h.key(999) #=> nil
--
A separation of the races is the only perfect preventive of amalgamation; but
as an immediate separation is impossible, the next best thing is to keep them
apart where they are not already together. If white and black people never get
together in Kansas, they will never mix blood in Kansas.
--- A. Lincoln, June 26, 1857