On Nov 25, 12:54 am, dokondr <[EMAIL PROTECTED]> wrote:
> How can I write the following examples in Clojure that in Haskell will
> be:
>
> --  1) Curried function:
> Prelude> let f = (+) 1
> Prelude> f 1
> 2
>
> -- 2) Anonymous function:
> Prelude> let f2 = \x -> x * 2
> Prelude> f2 2
> 4
>
> -- 3) Function composition:
> Prelude> (f2 . f) 3
> 8
> Prelude>

1) (def fn1 (partial + 1))
2) (def fn2 #(* % 2)) or (fn [x] (* x 2)))
3) ((comp fn2 fn1) 3)

--
Jarkko


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