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

Re: Hash to list?

28 views
Skip to first unread message

WJ

unread,
Mar 15, 2012, 8:48:55 AM3/15/12
to
Why this is marked as abuse? It has been marked as abuse.
Report not abuse
Hannu Koivisto wrote:

> Ola Rinta-Koski <ola.rinta-ko...@iki.fi.no.spam.today> writes:
>
> | Is there an easier way to convert a hash table into a list than
>
> Values of a hash table, based on your example, right?
>
> | this? If not easier, how about an alternative where it could be done
> | already in the LET declaration?
>
> (let ((value-list (loop for i being each hash-value of hash-table
> collect i)))
> ...)


Clojure:

(vals {:a "foo", :b "bar"})
==> ("foo" "bar")

WJ

unread,
Oct 19, 2012, 9:39:50 AM10/19/12
to
Why this is marked as abuse? It has been marked as abuse.
Report not abuse
WJ wrote:

> Hannu Koivisto wrote:
>
> > Ola Rinta-Koski <ola.rinta-ko...@iki.fi.no.spam.today> writes:
> >
> > > Is there an easier way to convert a hash table into a list than
> >
> > Values of a hash table, based on your example, right?
> >
> > > this? If not easier, how about an alternative where it could be done
> > > already in the LET declaration?
> >
> > (let ((value-list (loop for i being each hash-value of hash-table
> > collect i)))
> > ...)
>

Instead of DARPA CL, let's use a Lispy language.

Racket:

: (hash 'a 2 'b 3)
'#hash((b . 3) (a . 2))
: (hash-values (hash 'a 2 'b 3))
'(3 2)
0 new messages