Re: Newbie question about anonymous functions

2009-08-02 Thread samppi
Also, identity works too: #(identity "foo") ; equivalent to (fn [] "foo") On Aug 2, 10:04 am, Meikel Brandmeyer wrote: > Hi, > > Am 02.08.2009 um 17:56 schrieb Sean Devlin: > > > 1.  Use quote > > > #(quote "foo") > > For this approach I would recommend `do`: > > (let [x 5] #(quote x)) ; *meeep

Re: Newbie question about anonymous functions

2009-08-02 Thread Meikel Brandmeyer
Hi, Am 02.08.2009 um 17:56 schrieb Sean Devlin: 1. Use quote #(quote "foo") For this approach I would recommend `do`: (let [x 5] #(quote x)) ; *meeep* (let [x 5] #(do x)) Other than that I would recommend `constantly` in this case, because it carries the intention, while the #(do ..) look

Re: Newbie question about anonymous functions

2009-08-02 Thread Sean Devlin
There are two other ways to write (fn [x] "foo") 1. Use quote #(quote "foo") 2. Use the constantly function (constantly "foo") Both return a constant value. Sean On Aug 2, 7:47 am, Jarkko Oranen wrote: > Chad Harrington wrote: > > I have a ne

Re: Newbie question about anonymous functions

2009-08-02 Thread Jarkko Oranen
Chad Harrington wrote: > I have a newbie question about anonymous functions. Why does the first form > below work and the second form does not? > > user> ((fn [] "foo")) > "foo" > > user> (#("foo")) > ; Evaluation aborted. fn and #

Newbie question about anonymous functions

2009-08-02 Thread Chad Harrington
I have a newbie question about anonymous functions. Why does the first form below work and the second form does not? user> ((fn [] "foo")) "foo" user> (#("foo")) ; Evaluation aborted. Thanks, Chad --~--~-~--~~~---~--~~ You r