[plt-scheme] Why do layman programmers care about Currying?

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Wed Dec 31 18:18:27 EST 2008

You could imagine a world that looks like this:

#lang scheme

(define (fcore a b c)
   (+ a b c))

(define (f #:a (a #f) #:b (b #f) #:c (c #f))
   (cond
     [(and a b c) (fcore a b c)]
     [(and a b) (lambda (c) (fcore a b c))]
     [(and a c) (lambda (b) (fcore a b c))]
     [(and b c) (lambda (a) (fcore a b c))]
     [a (lambda (b c) (fcore a b c))]
     [b (lambda (a c) (fcore a b c))]
     [c (lambda (a b) (fcore a b c))]))

((f #:a 0) 1 2)
((f #:a 0 #:c 2) 1)
..

John Lamping explored this form of abstraction in his dissertation  
and I always thought there was something neat about it.

-- Matthias



On Dec 31, 2008, at 12:44 AM, Richard Cleis wrote:

>
> On Dec 30, 2008, at 9:12 PM, Grant Rettke wrote:
>
>> Why do layman (working programmers) care about Currying? Or how are
>> they applied in daily use to help one out?
>>
>> http://en.wikipedia.org/wiki/Currying
>
>
> On Dec 30, 2008, at 9:12 PM, Grant Rettke wrote:
>
>> Why do layman (working programmers) care about Currying? Or how are
>> they applied in daily use to help one out?
>
> I'm not sure if you are referring to 'using a function that curries  
> other functions,' or if you mean (as the wikisnip says) "if you fix  
> some arguments, you get a function of the remaining arguments." I  
> manually do the latter frequently, and it's one of the reasons I  
> like Scheme so much.
>
> However, I am not certain that Currying refers to reducing the  
> arguments in any order.  I have the impression that Currying  
> literally means reducing them in the order that they appear so that  
> other functions may be written to take advantage of such  
> strictness.  Freeform reduction of arguments is simply making use  
> of closures.  No?
>
> rac
>
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.