How can you implement Composite keys in clojure? If I have a map where First and last name, for example, point to a list of attributes .... Could I make a map that contained bo开发者_如何学运维th fields as the key?
And meanwhile ... In java you can override "equals" to make very advanced keys for maps... How are sophisticated keys implemented in clojure?
You can use any kind of object that correctly implements equals as a key. For clojure, that includes all the collection types, so you can just use a standard clojure collection as the key. Example using a two-element vectors as keys:
(def foo {[1 2] :bar [3 4] :baz})
=> #'user/foo
(foo [1 2])
=> :bar
精彩评论