Apply a list of function to parameter, clojure -


(def ops '(+ - * /)) (map #(% 2 5) ops) 

gives

(5 5 5 5) 

this doesn't make sense me. why return list of 5 instead of results of function calls?

the problem '(+ - * /) list of symbols, not list of functions. symbols implement afn , when supplied 2 arguments, function attempts symbol in first argument (2 here) , returns second argument (5 here) if lookup fails.


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -