Justin Smith <noisesm...@gmail.com> writes:

Hi Justin & Hans-Peter,

> Typically in clojure we use hash-maps (represented literally as {})
> where other lisps would use an alist.

One difference between alists and maps is that in alists a "key" can
occur multiple times, and then the first entry with that key shadows all
following entries with that key (with respect to retrieval with
`assoc`).

Well, that feature is probably not used very often, but if you can't
rule out its usage, you also can't convert alists to maps and expect
they're equivalent.

> Regarding reading assoc list literals, I wouldn't be surprised if
> someone had written this function already, but I doubt it is in the
> core language.

This should do the trick:

  (defn alist-assoc [key alist]
    (first (filter #(= key (first %)) alist)))

And to add a list to an alist one would use `cons` in Clojure just like
one would use `cons` in CL, Scheme, or Elisp, too.

Bye,
Tassilo

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to