Re: What's your preference, partial or closures?

2013-08-19 Thread Ben Wolfson
Counterpoint! He's not crazy:
https://github.com/bwo/monads/blob/master/src/monads/util.clj#L8-43


On Sun, Aug 18, 2013 at 9:20 PM, Sean Corfield seancorfi...@gmail.comwrote:

 You're crazy :)

 On Sun, Aug 18, 2013 at 9:04 PM, Chris Allen callen.2...@gmail.com
 wrote:
  Am I crazy or does this scream macro?
 
  On Saturday, August 17, 2013 6:02:03 PM UTC-7, Sean Corfield wrote:
 
  On Sat, Aug 17, 2013 at 5:43 PM, yair yair...@gmail.com wrote:
   What do you mean by currying in this context?  Is there a way to do
 this
   in
   clojure apart from using partial?
 
  (defn some-func
([a b c] (process a b c))
([a b]   (fn [c] (some-func a b c)))
([a] (fn ([b] (fn [c] (some-func a b c)))
 ([b c] (some-func a b c)
 
  (some-func 1 2 3)
  ((some-func 1 2) 3)
  (((some-func 1) 2) 3)
  ((some-func 1) 2 3)
  --
  Sean A Corfield -- (904) 302-SEAN
  An Architect's View -- http://corfield.org/
  World Singles, LLC. -- http://worldsingles.com/
 
  Perfection is the enemy of the good.
  -- Gustave Flaubert, French realist novelist (1821-1880)
 
  --
  --
  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 unsubscribe from this group, send email to
  clojure+unsubscr...@googlegroups.com
  For more options, visit this group at
  http://groups.google.com/group/clojure?hl=en
  ---
  You received this message because you are subscribed to the Google Groups
  Clojure group.
  To unsubscribe from this group and stop receiving emails from it, send an
  email to clojure+unsubscr...@googlegroups.com.
  For more options, visit https://groups.google.com/groups/opt_out.



 --
 Sean A Corfield -- (904) 302-SEAN
 An Architect's View -- http://corfield.org/
 World Singles, LLC. -- http://worldsingles.com/

 Perfection is the enemy of the good.
 -- Gustave Flaubert, French realist novelist (1821-1880)

 --
 --
 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 unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
Ben Wolfson
Human kind has used its intelligence to vary the flavour of drinks, which
may be sweet, aromatic, fermented or spirit-based. ... Family and social
life also offer numerous other occasions to consume drinks for pleasure.
[Larousse, Drink entry]

-- 
-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: What's your preference, partial or closures?

2013-08-19 Thread Alan Shaw
I read those. Now I'm screaming :)
On Aug 18, 2013 11:40 PM, Ben Wolfson wolf...@gmail.com wrote:

 Counterpoint! He's not crazy:
 https://github.com/bwo/monads/blob/master/src/monads/util.clj#L8-43


 On Sun, Aug 18, 2013 at 9:20 PM, Sean Corfield seancorfi...@gmail.comwrote:

 You're crazy :)

 On Sun, Aug 18, 2013 at 9:04 PM, Chris Allen callen.2...@gmail.com
 wrote:
  Am I crazy or does this scream macro?
 
  On Saturday, August 17, 2013 6:02:03 PM UTC-7, Sean Corfield wrote:
 
  On Sat, Aug 17, 2013 at 5:43 PM, yair yair...@gmail.com wrote:
   What do you mean by currying in this context?  Is there a way to do
 this
   in
   clojure apart from using partial?
 
  (defn some-func
([a b c] (process a b c))
([a b]   (fn [c] (some-func a b c)))
([a] (fn ([b] (fn [c] (some-func a b c)))
 ([b c] (some-func a b c)
 
  (some-func 1 2 3)
  ((some-func 1 2) 3)
  (((some-func 1) 2) 3)
  ((some-func 1) 2 3)
  --
  Sean A Corfield -- (904) 302-SEAN
  An Architect's View -- http://corfield.org/
  World Singles, LLC. -- http://worldsingles.com/
 
  Perfection is the enemy of the good.
  -- Gustave Flaubert, French realist novelist (1821-1880)
 
  --
  --
  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 unsubscribe from this group, send email to
  clojure+unsubscr...@googlegroups.com
  For more options, visit this group at
  http://groups.google.com/group/clojure?hl=en
  ---
  You received this message because you are subscribed to the Google
 Groups
  Clojure group.
  To unsubscribe from this group and stop receiving emails from it, send
 an
  email to clojure+unsubscr...@googlegroups.com.
  For more options, visit https://groups.google.com/groups/opt_out.



 --
 Sean A Corfield -- (904) 302-SEAN
 An Architect's View -- http://corfield.org/
 World Singles, LLC. -- http://worldsingles.com/

 Perfection is the enemy of the good.
 -- Gustave Flaubert, French realist novelist (1821-1880)

 --
 --
 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 unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




 --
 Ben Wolfson
 Human kind has used its intelligence to vary the flavour of drinks, which
 may be sweet, aromatic, fermented or spirit-based. ... Family and social
 life also offer numerous other occasions to consume drinks for pleasure.
 [Larousse, Drink entry]

  --
 --
 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 unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: What's your preference, partial or closures?

2013-08-18 Thread Mikera
I prefer to use closures / higher order functions that return a function. 
Reasons:
- You typically get much better performance by returning a closure. 
partial uses apply, which adds a lot of overhead
- It can result in cleaner user code (partials require a bit of mental 
decoding, and you can give the closure-returning function a good, specific 
name)

On naming, I like to use the er suffix to imply that the return value is 
a function that will perform the relevant task. e.g.

(defn incrementer [value]
  (fn [x] (+ x value)))

((incrementer 3) 10)
= 13

On Saturday, 17 August 2013 06:00:30 UTC+8, nodename wrote:

 (defn newgrid 

   [m initialize qi qj]... 


 and then (let [init (partial newgrid m initialize)]... 


 Or else: 


 (defn newgrid 

   [m initialize] 

   (fn [qi qj]... 


 and then (let [init (newgrid m initialize)]... 


-- 
-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: What's your preference, partial or closures?

2013-08-18 Thread Chris Allen
Am I crazy or does this scream macro?

On Saturday, August 17, 2013 6:02:03 PM UTC-7, Sean Corfield wrote:

 On Sat, Aug 17, 2013 at 5:43 PM, yair yair...@gmail.com javascript: 
 wrote: 
  What do you mean by currying in this context?  Is there a way to do this 
 in 
  clojure apart from using partial? 

 (defn some-func 
   ([a b c] (process a b c)) 
   ([a b]   (fn [c] (some-func a b c))) 
   ([a] (fn ([b] (fn [c] (some-func a b c))) 
([b c] (some-func a b c) 

 (some-func 1 2 3) 
 ((some-func 1 2) 3) 
 (((some-func 1) 2) 3) 
 ((some-func 1) 2 3) 
 -- 
 Sean A Corfield -- (904) 302-SEAN 
 An Architect's View -- http://corfield.org/ 
 World Singles, LLC. -- http://worldsingles.com/ 

 Perfection is the enemy of the good. 
 -- Gustave Flaubert, French realist novelist (1821-1880) 


-- 
-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: What's your preference, partial or closures?

2013-08-18 Thread Sean Corfield
You're crazy :)

On Sun, Aug 18, 2013 at 9:04 PM, Chris Allen callen.2...@gmail.com wrote:
 Am I crazy or does this scream macro?

 On Saturday, August 17, 2013 6:02:03 PM UTC-7, Sean Corfield wrote:

 On Sat, Aug 17, 2013 at 5:43 PM, yair yair...@gmail.com wrote:
  What do you mean by currying in this context?  Is there a way to do this
  in
  clojure apart from using partial?

 (defn some-func
   ([a b c] (process a b c))
   ([a b]   (fn [c] (some-func a b c)))
   ([a] (fn ([b] (fn [c] (some-func a b c)))
([b c] (some-func a b c)

 (some-func 1 2 3)
 ((some-func 1 2) 3)
 (((some-func 1) 2) 3)
 ((some-func 1) 2 3)
 --
 Sean A Corfield -- (904) 302-SEAN
 An Architect's View -- http://corfield.org/
 World Singles, LLC. -- http://worldsingles.com/

 Perfection is the enemy of the good.
 -- Gustave Flaubert, French realist novelist (1821-1880)

 --
 --
 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 unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.



-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

Perfection is the enemy of the good.
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: What's your preference, partial or closures?

2013-08-17 Thread yair
What do you mean by currying in this context?  Is there a way to do this in 
clojure apart from using partial?

On Saturday, August 17, 2013 10:04:23 AM UTC+10, Sean Corfield wrote:

 I went down the partial path for a long time but have moved more and 
 more toward currying and closures lately as it seems to produce 
 cleaner code - and this also seems to be the way Clojure/core have 
 moved with the reducers library and other places...? 

 Sean 

 On Fri, Aug 16, 2013 at 3:00 PM, Alan Shaw node...@gmail.comjavascript: 
 wrote: 
  (defn newgrid 
  
[m initialize qi qj]... 
  
  
  and then (let [init (partial newgrid m initialize)]... 
  
  
  Or else: 
  
  
  (defn newgrid 
  
[m initialize] 
  
(fn [qi qj]... 
  
  
  and then (let [init (newgrid m initialize)]... 
  
  -- 
  -- 
  You received this message because you are subscribed to the Google 
  Groups Clojure group. 
  To post to this group, send email to clo...@googlegroups.comjavascript: 
  Note that posts from new members are moderated - please be patient with 
 your first post. 
  To unsubscribe from this group, send email to 
  clojure+u...@googlegroups.com javascript: 
  For more options, visit this group at 
  http://groups.google.com/group/clojure?hl=en 
  --- 
  You received this message because you are subscribed to the Google 
 Groups Clojure group. 
  To unsubscribe from this group and stop receiving emails from it, send 
 an email to clojure+u...@googlegroups.com javascript:. 
  For more options, visit https://groups.google.com/groups/opt_out. 



 -- 
 Sean A Corfield -- (904) 302-SEAN 
 An Architect's View -- http://corfield.org/ 
 World Singles, LLC. -- http://worldsingles.com/ 

 Perfection is the enemy of the good. 
 -- Gustave Flaubert, French realist novelist (1821-1880) 


-- 
-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: What's your preference, partial or closures?

2013-08-17 Thread Sean Corfield
On Sat, Aug 17, 2013 at 5:43 PM, yair yair@gmail.com wrote:
 What do you mean by currying in this context?  Is there a way to do this in
 clojure apart from using partial?

(defn some-func
  ([a b c] (process a b c))
  ([a b]   (fn [c] (some-func a b c)))
  ([a] (fn ([b] (fn [c] (some-func a b c)))
   ([b c] (some-func a b c)

(some-func 1 2 3)
((some-func 1 2) 3)
(((some-func 1) 2) 3)
((some-func 1) 2 3)
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

Perfection is the enemy of the good.
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


What's your preference, partial or closures?

2013-08-16 Thread Alan Shaw
(defn newgrid

  [m initialize qi qj]...


and then (let [init (partial newgrid m initialize)]...


Or else:


(defn newgrid

  [m initialize]

  (fn [qi qj]...


and then (let [init (newgrid m initialize)]...

-- 
-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: What's your preference, partial or closures?

2013-08-16 Thread Sean Corfield
I went down the partial path for a long time but have moved more and
more toward currying and closures lately as it seems to produce
cleaner code - and this also seems to be the way Clojure/core have
moved with the reducers library and other places...?

Sean

On Fri, Aug 16, 2013 at 3:00 PM, Alan Shaw noden...@gmail.com wrote:
 (defn newgrid

   [m initialize qi qj]...


 and then (let [init (partial newgrid m initialize)]...


 Or else:


 (defn newgrid

   [m initialize]

   (fn [qi qj]...


 and then (let [init (newgrid m initialize)]...

 --
 --
 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 unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups 
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.



-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

Perfection is the enemy of the good.
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.