Re:Usefulness of inventing programming languages
by jkkramer on Tuesday April 26, 2011 @12:18PM
(#2485906)
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)
Re:Usefulness of inventing programming languages
by emilis_info on Tuesday April 26, 2011 @01:51PM
(#2486356)
Thank you! One more reason to use Clojure...
I think there may be both advantages and disadvantages in unifying function calls and dictionary queries. The reason I am asking the question is that I haven't been able to try it for myself (or at least read about someones experience with it).
And I will try exposing myself to more languages :-)