Thanks for the reply!
 
If I understand your problem statement this is something I'd currently
solve using closures, is there a way that using currying is
fundamentally different or is it a different way of thinking about the
same problem?
 
----------->Nathan


________________________________

        From: jquery-en@googlegroups.com
[mailto:[EMAIL PROTECTED] On Behalf Of Rhapidophyllum
        Sent: Tuesday, April 17, 2007 6:36 PM
        To: jquery-en@googlegroups.com
        Subject: [jQuery] Re: Library showdowns
        
        
        There are some situations when you can only pass a variable
referring to a function; with a curry function you can pass a variable
that refers to a function + arguments.   
        A problem, though, is that some curry functions seem to go a
little beyond this basic functionality, behaving differently with
different numbers of arguments.  (I'm thinking of the dojo curry
function, which is based on one from a certain language.)  I don't
follow it exactly when it does this, but it makes me leery of using it.


        On Apr 17, 2007, at 6:38 PM, Nathan Young -X ((natyoung -
Artizen at Cisco)) wrote:


                Hi.
                 
                Can you describe a problem whose solution becomes much
easier by using currying?
                 
                ----->Nathan


________________________________

                        From: jquery-en@googlegroups.com
[mailto:[EMAIL PROTECTED] On Behalf Of Sean Catchpole
                        Sent: Monday, April 16, 2007 8:17 PM
                        To: jquery-en@googlegroups.com
                        Subject: [jQuery] Re: Library showdowns
                        
                        
                        Jeffrey and Glen,
                        
                        Allow me to explain currying. Imagine if you
will the following function (written in javascript)
                        add = function (a,b) { return a+b }
                        I can now call add(3,7) and it will return 10.
                        A language that allows currying would allow me
to pass only one variable and it would return a new function that takes
a single variable. ex: add(3) would return a function that adds three to
the input. Here is an example way of implementing it in javascript:
                        add = function (a) { return function (b) {
return a+b } }
                        Now I can call add(3) and it will return
function (b) { return 3+b } 
                        In the same sense as the first example we can
now call add(3)(7) and it will return 10.
                        
                        This allows for lots of cleverness in use of
functions and ultimately make functions far more reusable. I consider it
a great advantage of functional programming. So as you can see, the same
effect can be created, but it's tedious. I'm trying to come up with a
trickier way so that it's not so painful to create a curried function in
javascript. 
                        
                        
                        ~Sean 


Reply via email to