Hello everybody,
recently I was using the following pattern a lot, in order to get access to
a value inside a map:
(defn map-geto* [m k v]
(matche [m]
([[[k v] . _]])
([[_ . tail]] (map-geto* tail k v))))
I can use that like this:
(run* [q] (map-geto* (seq {:key "value"}) :key q))
>
which return ("value"). But after some thought I realized that I am
essentially doing a linear-search on the map instead of leveraging the
advantage of maps: fast-lookup of a value for a key.
So I wanted to ask: does anybody know of a way to re-write this function,
so it uses map-destructuring instead, while still being general enough so
it can be used on a map with any data?
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en