I trying to grok partial and - so I have the following example.
(defn f[x y] (+ x y))
((partial f 2) 3) works as expected , returning 5
but if I try to use -
(- 3 (partial f 2))
I get #core$partial$fn__3796 clojure.core$partial$fn__3796@4c629f43
But if I first define
(def fp (partial f 2))
reading material:
http://blog.fogus.me/2009/09/04/understanding-the-clojure-macro/
When you say (- 3 (partial f 2)) that evaluates to (partial 3 f 2) -
which is obviously not what you want.
Likewise, (- 3 fp) expands to (fp 3), which works fine, as you noticed.
The important thing to remember
Sorry, I meant to link this post:
http://blog.fogus.me/2010/09/28/thrush-in-clojure-redux/
On Mon, Apr 16, 2012 at 12:58 PM, Jay Fields j...@jayfields.com wrote:
reading material:
http://blog.fogus.me/2009/09/04/understanding-the-clojure-macro/
When you say (- 3 (partial f 2)) that evaluates
(- 3 ((partial f 2))) should also work.
--
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
Note that posts from new members are moderated - please be patient with your
first post.
To
On Monday, April 16, 2012 10:02:48 AM UTC-7, Cedric Greevey wrote:
(- 3 ((partial f 2))) should also work.
I just wrote that it DOESN'T WORK. That's the point of the question.I
should get 5 instead I get
t#core$partial$fn__3796 clojure.core$partial$fn__3796@4c629f43
--
You received
Compare the number of brackets in Cedric's example to yours.
Ambrose
On Tue, Apr 17, 2012 at 1:18 PM, larry larrye2...@gmail.com wrote:
On Monday, April 16, 2012 10:02:48 AM UTC-7, Cedric Greevey wrote:
(- 3 ((partial f 2))) should also work.
I just wrote that it DOESN'T WORK. That's
user= (defn f[x y] (+ x y))
#'user/f
user= (- 3 ((partial f 2)))
5
It must works :). Please notice the extra parentheses.
2012/4/17 larry larrye2...@gmail.com
On Monday, April 16, 2012 10:02:48 AM UTC-7, Cedric Greevey wrote:
(- 3 ((partial f 2))) should also work.
I just wrote that it
On Mon, Apr 16, 2012 at 10:18 PM, larry larrye2...@gmail.com wrote:
On Monday, April 16, 2012 10:02:48 AM UTC-7, Cedric Greevey wrote:
(- 3 ((partial f 2))) should also work.
I just wrote that it DOESN'T WORK. That's the point of the question.I
should get 5 instead I get