Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In Clojure, hash maps are functions of their keys. If you use keywords as keys, then keywords are also functions of maps.

    ({:a 1} :a)
    => 1

    (:a {:a 1})
    => 1

    (map {2 4} [1 2 3])
    => (nil 4 nil)

    (map {:a 1 :b 2 :c 3} [:a :b :c])
    => (1 2 3)


Thank you! One more reason to use Clojure...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: