Re: how to interrupt maphash

Gary King <[email protected]> Thu, 27 Apr 2006 23:26:37 -0400
Newsgroups gmane.lisp.allegro
Message-ID <[email protected]>
The easiest method is the lisp return-from form. For example:

(let ((ht (make-hash-table)))
   (setf (gethash :a ht) 1
         (gethash :b ht) 2
         (gethash :c ht) 3
         (gethash :d ht) 4)
   (block stop-mapping
     (maphash
      (lambda (k v)
        (format t "~%~A ~A" k v)
        (when (oddp v)
          (return-from stop-mapping)))
      ht)))



On Apr 27, 2006, at 7:10 PM, Yaling Zheng wrote:

>
> Does anybody know how to interrupt maphash?
> Is there another construct I should use for that purpose?
>
> Thank you,
>
> Yaling
>


-- 
Gary Warren King
metabang.com
http://www.metabang.com/
(413) 210 7511
gwking on #lisp (occasionally)