On 18 April 2010 19:36, Joop Kiefte <iko...@gmail.com> wrote:
> you can do #(identity 1)

Or #(do 1).

> 2010/4/18 Yonov <myo...@gmail.com>
>>
>> Thanks, a lot!
>> It seems that there is no nice way to make a shortened lambda function
>> which returns an integer.
>> I mean #(1) is not OK, and #1 is not OK. Although there is no problem
>> with this (fn [] 1).

That's because #(1) expands to:

user=> (macroexpand-1 '#(1))
(fn* [] (1))

but you don't want the parentheses around the 1.  So for #(xxx), xxx
needs to be a function.  This is why something like #(do 1) or
#(identity 1) works:

user=> (macroexpand-1 '#(do 1))
(fn* [] (do 1))
user=> (do 1)
1
user=> (macroexpand-1 '#(identity 1))
(fn* [] (identity 1))
user=> (identity 1)
1

-- 
Michael Wood <esiot...@gmail.com>

-- 
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

Reply via email to