[plt-scheme] idiomatic way to get keys and values

From: Carl Eastlund (carl.eastlund at gmail.com)
Date: Fri Jan 1 21:46:10 EST 2010

On Fri, Jan 1, 2010 at 7:51 PM, Todd O'Bryan <toddobryan at gmail.com> wrote:
> If I have a hash table h, I can get the keys and values
>
> (let
>  ([keys (hash-map h (lambda (k v) k))]
>   [values (hash-map h (lambda (k v) v)])
>
> but that seems kind of klunky. Is there a more idiomatic way that I'm
> not thinking of?
>
> Todd

I'd do it this way:

(match h
  [(hash-table [keys values] ...)
   ...body here...])

--Carl


Posted on the users mailing list.