Let's say that I have the following map in Clojure:
(def person {:name "Jack" :say-hello #(print "hello")})
Question 1: Is it possible to call the anonymous function of key :say-hello? How?
Question 2 Is it possible to instantiate / clone person vector with different values?
(:say-hello person) returns the function, so ((:say-hello person)) calls it.
The function is just a value like all other values, so you can pass it around and create new maps from it.
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