> As you've already seen, if you just want the original value returned > from a function, you can call the 'identity' function with that > something as an argument, as in #(identity %) or #(identity true), > etc.
I should have also made clear here that you would never actually use this in real code, just for learning. See the other responses for the actual ways to do what you are trying to do. On Wed, Sep 7, 2011 at 8:24 AM, Mark Rathwell <mark.rathw...@gmail.com> wrote: >> How about this: >> >> (#(true)), is this not calling a function that has no arguments and >> returns true? But it still gives same exception > > This actually is trying to call 'true' as if it were a function, not a > constant. The thing I think you're missing here is: when a symbol is > butted up against an opening parenthesis, it is treated as a function > call, with the remaining elements in the list as arguments (unless the > list is quoted, in which case it is not evaluated and treated as just > a list). > > #(true) says call 'true' as a function with no arguments. #(%) says > call the argument passed to this anonymous function as a function, and > if, for example you were mapping a vector of numbers to this anonymous > function, then each number would be called as a function. > > As you've already seen, if you just want the original value returned > from a function, you can call the 'identity' function with that > something as an argument, as in #(identity %) or #(identity true), > etc. > -- 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