Re: function creation, partial or #()

2013-08-17 Thread Sean Corfield
Gosh darn... yes, that is what I want. That must be the only combination of things I didn't try! Thank you. On Sat, Aug 17, 2013 at 4:18 AM, Jay Fields wrote: > Sean, it sounds like you want > > (swap! some-a update-in [:k1 :k2] (fnil conj []) id) > > But that's based on some pretty limited conte

Re: function creation, partial or #()

2013-08-17 Thread Jay Fields
Sean, it sounds like you want (swap! some-a update-in [:k1 :k2] (fnil conj []) id) But that's based on some pretty limited context. On Friday, August 16, 2013, Sean Corfield wrote: > On Fri, Aug 16, 2013 at 4:32 PM, Timothy Baldridge > > > wrote: > > I'm just going to throw this out there, but

Re: function creation, partial or #()

2013-08-17 Thread Jay Fields
Thanks everyone. Seems like there's pretty solid agreement on which solution is preferred. Cheers, Jay On Saturday, August 17, 2013, David Chelimsky wrote: > On Fri, Aug 16, 2013 at 9:49 PM, Gregg Reynolds > > > wrote: > >> On Tue, Aug 13, 2013 at 1:50 PM, John D. Hume >> > 'duelin.mark...@gm

Re: function creation, partial or #()

2013-08-16 Thread David Chelimsky
On Fri, Aug 16, 2013 at 9:49 PM, Gregg Reynolds wrote: > On Tue, Aug 13, 2013 at 1:50 PM, John D. Hume > wrote: > > Though in some cases the performance impact could be significant, my > concern > > is readability. My understanding of the concept of partial function > > application is that it's

Re: function creation, partial or #()

2013-08-16 Thread Sean Corfield
On Fri, Aug 16, 2013 at 4:32 PM, Timothy Baldridge wrote: > I'm just going to throw this out there, but I almost always consider using > #() instead of (fn []) to be bad practice. I still use #() for anonymous single argument functions that are small, single forms, but I've started switching to (

Re: function creation, partial or #()

2013-08-16 Thread Alex Baranosky
My two cents: The way I see it, the use of #( ... % ...) is analogous to the usage of the word "it" in English: only use it when it is obvious beyond a shadow of a doubt what "it" means. Think about how clunky English would be without the word "it". On Fri, Aug 16, 2013 at 4:32 PM, Timothy Bald

Re: function creation, partial or #()

2013-08-16 Thread Timothy Baldridge
I'm just going to throw this out there, but I almost always consider using #() instead of (fn []) to be bad practice. Like all syntactic sugar, it has its place, but I reach for fn more often then not, because it allows me to name the arguments and track in my mind the data with which I am working.

Re: function creation, partial or #()

2013-08-16 Thread Gregg Reynolds
On Tue, Aug 13, 2013 at 1:50 PM, John D. Hume wrote: > Though in some cases the performance impact could be significant, my concern > is readability. My understanding of the concept of partial function > application is that it's about supplying some but not all of the arguments. > So when I see `p

Re: function creation, partial or #()

2013-08-16 Thread Tim Visher
I will also note that any lamdba of more than one (_maybe_ two) args _must_, for me, be in the `(fn […] …)` form. Not only does it have the advantage of taking the function name, but it also is much easier to read what it's doing when I can explicitly name it's inputs. On Fri, Aug 16, 2013 at 7:3

Re: function creation, partial or #()

2013-08-16 Thread Stefan Kamphausen
On Friday, August 16, 2013 9:45:53 AM UTC+2, Antonio Terreno wrote: > > > I much prefer the #(), (fn[]) is longer so it's a no-go ;) > > > fn has the huge advantage of taking an (optional) name, which will show up in stack traces. Just my 2ct Stefan -- -- You received this message because

Re: function creation, partial or #()

2013-08-16 Thread Antonio Terreno
As a newbie I got confused in the first place looking at codebases where partial was used, like your colleague said, it's in the docs: "Takes a function f and fewer than the normal arguments to f, and returns a fn that takes a variable number of additional args. When called, the returned function

Re: function creation, partial or #()

2013-08-15 Thread Stefan Kamphausen
> (let [params (map (fn [_] (gensym "fnp-")) (range n))] > (repeatedly n #(gensym "fnp-")) Best, Stefan -- -- 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

Re: function creation, partial or #()

2013-08-14 Thread Stefan du Fresne
So I'm new to Clojure, and have been working through how to make Clojure code performant (i.e. what approaches are faster than others, how to profile, etc) by writing a (embarrassingly) simple ray-tracer. In a ray tracer there is a tight loop that runs per pixel, where you determine which of a

Re: function creation, partial or #()

2013-08-13 Thread John D. Hume
Though in some cases the performance impact could be significant, my concern is readability. My understanding of the concept of partial function application is that it's about supplying some but not all of the arguments. So when I see `partial` in code, I expect more arguments to be supplied later,

Re: function creation, partial or #()

2013-08-13 Thread Tim Visher
On Tue, Aug 13, 2013 at 8:47 AM, Jay Fields wrote: > Say you have a simple function: (defn do-work [f] (f)) > > When you want to call do-work you need a function, let's pretend we > want to use this function: (defn say-hello [n] (println "hello" n)) > > Which of the following solutions do you pref

Re: function creation, partial or #()

2013-08-13 Thread Max Penet
Hi, Partial calls apply, so it's not as performant as #(..). That can make quite the difference depending on where it's used. All instances of partial were removed recently in carmine/nippy and that resulted in quite a performance improvement. On Tuesday, August 13, 2013 2:47:01 PM UTC+2, Jay

Re: function creation, partial or #()

2013-08-13 Thread Jim - FooBar();
On 13/08/13 13:47, Jay Fields wrote: Say you have a simple function: (defn do-work [f] (f)) When you want to call do-work you need a function, let's pretend we want to use this function: (defn say-hello [n] (println "hello" n)) Which of the following solutions do you prefer? (do-work (partial

function creation, partial or #()

2013-08-13 Thread Jay Fields
Say you have a simple function: (defn do-work [f] (f)) When you want to call do-work you need a function, let's pretend we want to use this function: (defn say-hello [n] (println "hello" n)) Which of the following solutions do you prefer? (do-work (partial say-hello "bob")) (do-work #(say-hello