Hi Geoff,
You probably want a sorted-map-by:
user=> (sorted-map-by (fn [a b] (or (when (every? coll? [a b]) (when (= a
(reverse b)) 0)) -1)) [1 2] 42 [2 1] 42)
{[1 2] 42}
Thanks,
Ambrose
On Fri, Jul 25, 2014 at 9:52 AM, Geoff Little <[email protected]> wrote:
> I'm attempting to proxy PersistentHashmap so that "get"ting an existing
> key or its reverse returns the same value.
>
> Here's the code that I have
>
> (defn sym-key-hash-map []
> (proxy [clojure.lang.PersistentHashMap] [nil 0 nil false nil]
> (valAt [key]
> (or (proxy-super valAt key)
> (proxy-super valAt (reverse key))))))
>
> (let [key (list 1 2)]
> (get (assoc (sym-key-hash-map) key "sweet")
> (reverse key)))
>
> But unfortunately, the test code returns nil instead of "sweet".
>
> Does anyone with knowledge of proxy and PersistentHashmap know how to
> solve this?
>
> Thanks.
>
> --
> 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
> ---
> 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 [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
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
---
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 [email protected].
For more options, visit https://groups.google.com/d/optout.