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 both 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With