Maps are functions from docs :
Cards implement IFn, for invoke () one argument (key) with an optional second argument (default value), that is, cards are functions of their keys. nil keys and values ββare ok.
So this is:
({:x 10, :y 20, :z 50} :y)
applies the function {:x 10, :y 20, :z 50}
to :y
.
Keywords are also functions, quoting docs :
Keywords implement IFn for invoke () of one argument (map) with an optional second argument (default value). For example (: mykey my-hash-map: none) means the same as (get my-hash-map: mykey: none)
So when you do:
(:y {:x 10, :y 20, :z 50})
you actually call :y
with {:x 10, :y 20, :z 50}
as an argument.
In principle, everything that implements IFn
and is in the way of classes can be considered as a function.
source share