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