Curried Functions

Curried Functions

Post by Denis Buen » Tue, 30 Aug 2005 23:19:32


All,

I get the sense that curried functions can be extremely useful for partial
computations. For example, as in the Paulson book,

fun infixApply x f y = f (x, y);
val reciprocal = infixApply 1.0 op/;
reciprocal 2.0;

-> val it = 0.5 : real

The infixApply function actually defines an entire class of functions. But I'd
like to see something more powerful that can be done with curried functions.

Does anyone have any killer example?

-Denis
 
 
 

Curried Functions

Post by Mike Austi » Wed, 31 Aug 2005 05:00:38


It's such a fundamental concept that I don't think there is any 'killer
example'. Curry can simply be defined as 'curry f x = \y -> f x y'. Use it
wherever applicable.

Here's a few examples:
http://www.yqcomputer.com/ #head-5e481d64ce1e19a3618ff7c6a9aee9accc0f72e8


Mike

 
 
 

Curried Functions

Post by Lauri Alan » Wed, 31 Aug 2005 21:07:47

In article <GPJQe.148188$ XXXX@XXXXX.COM >,


Uh, that is the identity function, modulo eta. You probably meant
'curry f x y = f (x, y)' (or, more explicitly,
'curry f = \x -> \y -> f (x,y)').


Lauri
 
 
 

Curried Functions

Post by Mike Austi » Thu, 01 Sep 2005 04:37:54


Exactly. :)
Mike
 
 
 

Curried Functions

Post by Gianluca M » Sun, 11 Sep 2005 00:50:40


don't know if if is a killer application, but whenever
I need similar function, I can write a general function
and then curry it.

let gen f par =
general computation
particular computation via f

let f1 =
particular computation 1
let f2 =
particular computation 2

let mypart1 = gen f1

let mypart2 = gen f2

bye
--
Gianluca Moro Visit http://www.yqcomputer.com/
XXXX@XXXXX.COM MyBlog http://www.yqcomputer.com/
 
 
 

Curried Functions

Post by Ewan » Tue, 13 Sep 2005 16:17:31

Currying doesn't perform the partial evaluation you seem to be assuming
it will. Currying is only an argument passing technique. Partial
evaluation is a related but separate concern.

Check these URLs for more info:
http://www.yqcomputer.com/
http://www.yqcomputer.com/

Hope these help or are at least interesting.