Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: keys of hash table

12 views
Skip to first unread message

WJ

unread,
May 2, 2012, 5:37:51 AM5/2/12
to
Peter Van Eynde wrote:

> On 25 Jun 1999 13:31:18 +0100 (BST), Mark Carroll wrote:
>
> >I can't find an easy way of obtaining a list of the keys of a hash
> >table in Common Lisp. Can anyone do better than,
>
> >(defun keys-of-hash-table (ht)
> > (let ((keys nil))
> > (labels ((getkey (x y) (push x keys)))
> > (maphash #'getkey ht)
> > keys)))
>
> (defun keys-of-hash-table (ht)
> (loop for key being the hash-keys in ht
> collect key))

Racket:

> (hash-keys (hash 'a 1 'b 2 'c 3))
'(c b a)
0 new messages