Aha, got it. Just surprised me that it still worked without a map. Thanks for clearing it up!
Cheers On Tuesday, September 15, 2015 at 10:29:08 PM UTC-6, Carlo wrote: > > Symbols and keywords act as functions which look themselves up in their > argument. Essentially: > > ('sym map) => (get map 'sym) > ('sym map not-found) => (get map 'sym not-found) > > (:key map) => (get map :key) > (:key map not-found) => (get map :key not-found) > > It's often pretty useful, in my experience. It looks cleaner, and it > means that you can just use :keyword instead of #(get % :keyword) in > cases where you provide a function as an argument (for example: (map > :type objects)). > > On 16 September 2015 at 14:20, Michael O'Keefe <michael....@gmail.com > <javascript:>> wrote: > >> Hello All: >> >> Noticed the following works in Clojure 1.6 and 1.7 (didn't test prior to >> that): >> >> user=> ('+ 'a 'b) >> b >> >> Also "works" for any set of symbols: >> >> user=> ('abra 'ka 'dabra) >> dabra >> >> My expectation was that using symbols or keywords in the >> function/operator position would throw an exception similar to this: >> >> user=> (3 4) >> >> >> ClassCastException java.lang.Long cannot be cast to clojure.lang.IFn >> user/eval7668 (form-init2947310628177413729.clj:1) >> >> >> I noticed Keywords can also be used in the operator position: >> >> user=> (:abra :ka :dabra) >> :dabra >> >> And mixing and matching is OK: >> >> user=> (:a 'b 3) >> 3 >> >> It seems to act something like an implicit `do` in that it returns the >> last value but, in fact, not quite as you seem to need to have more than >> two items: >> >> user=> ('do) >> >> ArityException Wrong number of args (0) passed to: Symbol >> clojure.lang.AFn.throwArity (AFn.java:429) >> >> >> user=> ('do (+ 1 2 3)) >> nil >> >> >> user=> ('do 'this (+ 1 2 3)) >> 6 >> >> But more than 3 is not accepted: >> >> user=> ('do 'this 'please 3) >> >> >> ArityException Wrong number of args (3) passed to: Symbol >> clojure.lang.AFn.throwArity (AFn.java:429) >> >> user=> ('do 'this 'please 'now 'ok?) >> >> >> ArityException Wrong number of args (4) passed to: Symbol >> clojure.lang.AFn.throwArity (AFn.java:429) >> >> >> A quick search didn't reveal any bug reports or previous discussions on >> this but I may have missed something (feel free to point me in the right >> direction). >> >> Is it just a "quirk" or is it useful in some way? Intended behavior or >> bug? >> >> Cheers, >> >> Michael O'Keefe >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to clo...@googlegroups.com >> <javascript:> >> Note that posts from new members are moderated - please be patient with >> your first post. >> To unsubscribe from this group, send email to >> clojure+u...@googlegroups.com <javascript:> >> For more options, visit this group at >> http://groups.google.com/group/clojure?hl=en >> --- >> You received this message because you are subscribed to the Google Groups >> "Clojure" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to clojure+u...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.