For Programmers: Free Programming Magazines  


Home > Archive > Lisp > June 2005 > Removing hash entries during maphash









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Removing hash entries during maphash
V.Ch.

2005-06-07, 8:58 pm

Is it ok to remove hash table entries during maphash? For instance, is
it guaranteed that the following functions will work as expected:

(defun delete-odds (ht)
(maphash (lambda (k v)
(when (oddp k) (remhash k ht))) ht)
ht)

?
Lars Rune Nøstdal

2005-06-07, 8:58 pm

On Tue, 07 Jun 2005 23:08:35 +0400, V.Ch. wrote:

> Is it ok to remove hash table entries during maphash? For instance, is
> it guaranteed that the following functions will work as expected:
>
> (defun delete-odds (ht)
> (maphash (lambda (k v)
> (when (oddp k) (remhash k ht))) ht)
> ht)
>
> ?


http://www.lispworks.com/documentat...c/Body/03_f.htm

--
mvh,
Lars Rune Nøstdal
http://lars.nostdal.org/

Lars Rune Nøstdal

2005-06-07, 8:58 pm

On Tue, 07 Jun 2005 23:05:24 +0200, Lars Rune Nøstdal wrote:

> On Tue, 07 Jun 2005 23:08:35 +0400, V.Ch. wrote:
>
>
> http://www.lispworks.com/documentat...c/Body/03_f.htm


Oh, and this also talks about this:

http://www.lispworks.com/documentat...dy/f_maphas.htm

"The consequences are unspecified if any attempt is made to add or remove
an entry from the hash-table while a maphash is in progress, with two
exceptions: the function can use can use setf of gethash to change the
value part of the entry currently being processed, or it can use remhash
to remove that entry."

--
mvh,
Lars Rune Nøstdal
http://lars.nostdal.org/

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com