On 18 April 2010 19:36, Joop Kiefte <[email protected]> wrote:
> you can do #(identity 1)

Or #(do 1).

> 2010/4/18 Yonov <[email protected]>
>>
>> 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 <[email protected]>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to