On May 31, 5:20 am, Meikel Brandmeyer wrote:
> Am 31.05.2009 um 11:11 schrieb ataggart:
>
> (partial f a b) is equivalent to #(apply f a b %&). So anonymous
> functions are the more general, more powerful concept.
Ah, beautiful! Somehow I missed the %& form when reading the docs.
--~--~
Max et. al,
I'm impressed by your solutions to the problem. I still object to them
in practice, though, because they depend on either extra up-front work
(uncurry-n) or extra understanding on the part of the caller (:end,
'() and calling without parameters).
Haskell and the other ML langua
Hi,
Am 31.05.2009 um 11:11 schrieb ataggart:
On further consideration, having partial so the arity handling in non-
trivial cases is where it trumps an anonymous function.
(partial f a b) is equivalent to #(apply f a b %&). So anonymous
functions are the more general, more powerful concept.
On May 31, 1:55 am, Daniel Lyons wrote:
> On May 30, 2009, at 7:25 PM, kinghajj wrote:
>
>
>
> > On May 30, 1:19 pm, Daniel Lyons wrote:
> >> You can't have both partial application and variable arity functions.
>
> > Uh, yeah you can. Haskell can have variadic functions, like
> > Text.Printf.
On further consideration, having partial so the arity handling in non-
trivial cases is where it trumps an anonymous function.
On May 31, 2:04 am, ataggart wrote:
> On May 30, 12:58 pm, eyeris wrote:
>
> > The ubiquity of these anonymous functions
> > in clojure code is evidence that partial ap
On May 30, 12:58 pm, eyeris wrote:
> The ubiquity of these anonymous functions
> in clojure code is evidence that partial application is just as needed
> in clojure as it is in haskell.
Doesn't that depend entirely on whether or not the anonymous functions
are being used for partial applicatio
On May 30, 2009, at 7:25 PM, kinghajj wrote:
>
> On May 30, 1:19 pm, Daniel Lyons wrote:
>> You can't have both partial application and variable arity functions.
>
> Uh, yeah you can. Haskell can have variadic functions, like
> Text.Printf.printf, and with some explicit type signatures you can
On May 30, 1:19 pm, Daniel Lyons wrote:
> You can't have both partial application and variable arity functions.
Uh, yeah you can. Haskell can have variadic functions, like
Text.Printf.printf, and with some explicit type signatures you can
still partially apply it.
import Text.Printf
-- Here, I
On May 30, 2009, at 1:58 PM, eyeris wrote:
> If clojure used partial application by
> default, then we would see fewer anonymous functions in clojure code;
> if haskell did not use partial application by default, we would see
> more anonymous functions in haskell code.
You can't have both partia
>From a practical position, anonymous functions of the #(+ 5 %) flavor
*are* partial application. The ubiquity of these anonymous functions
in clojure code is evidence that partial application is just as needed
in clojure as it is in haskell. #(+ 5 %) is not much more succinct
than (\x -> x + 5).
On May 27, 11:57 pm, kinghajj wrote:
> Example:
> (def add5 ($ + 5))
>
> (add5 3)
I love partial application in haskell. But do not see the need for it
in clojure with its succinct syntax for anonymous functions:
(def add5 #(+ 5 %1))
(add5 3)
Besides clojure's anonymous function syntax allo
Bleh, I've been completely wrong about what currying does. Here's a
correct definition:
(defn curry [f]
(fn [a]
(fn [b] (f a b))
So curry basically takes a fn f that normally operates on a pair, and
creates an fn that "partially applies" f to an argument. That function
in turn will complet
Hey, here's a hacked together curry function that does it somewhat
like haskell, in pseudo-code. Can you guys help me correct it?
(defn curry [f & args1]
(cond (= (arity f ) (count args)) (apply f args1)
(fixed? (arity f) (fn [& args2] (curry (apply partial f
args1) args2)
On Thu, May 28, 2009 at 9:57 AM, kinghajj wrote:
>
> (defmacro $ [f & args]
> (let [args2 (gensym)]
> `(fn [& ~args2]
> (eval (cons (quote ~f) (concat (quote ~args) ~args2))
>
> Example:
> (def add5 ($ + 5))
>
> (add5 3)
This already exists :)
user=> (doc partial)
Here's a reason why a partial application macro is better than a
partial application function:
user=> ((partial or (prn "Hello")) (prn "World"))
java.lang.Exception: Can't take value of a macro: #'clojure.core/or
(NO_SOURCE_FILE:2)
user=> (($ or (prn "Hello")) (prn "World"))
"World"
"Hello"
nil
Here is a somewhat simpler definition :-) :
user=> (def $ clojure.core/partial)
#'user/$
user=> (def add5 ($ + 5))
#'user/add5
user=> (add5 3)
8
user=>
But maybe you want the delayed evaluation of the already included
arguments, but it is not clear to me from your e-mail (and your
example that u
(defmacro $ [f & args]
(let [args2 (gensym)]
`(fn [& ~args2]
(eval (cons (quote ~f) (concat (quote ~args) ~args2))
Example:
(def add5 ($ + 5))
(add5 3)
Beware! For this macro evaluates the later parameters before the
partially-applied ones, so side-effectful parameters may occu
17 matches
Mail list logo