partial application

Ketil Z. Malde ketil@ii.uib.no
19 Mar 2002 08:48:12 +0100


Koen Claessen <koen@cs.chalmers.se> writes:

> Suppose I have a function f which is defined to
> have 3 arguments:
> 
>   f x y z = ...
> 
> Now, when I want to partially apply f to two arguments, say
> 1 and 2, I can say this:
> 
>   ... (f 1 2) ...
> 
> However, if I want to leave out the middle argument, I have
> to say:
> 
>   ... (\y -> f 1 y 3) ...
> 
> And, similarly, for the first one:
> 
>   ... (\x -> f x 2 3) ...
> 
> This seems rather ugly, since the order of arguments in a
> function plays a crucial role. For example, the map function
> takes the list as its second argument, since it is so much
> more common to partially apply map with the function rather
> than the list.

        Prelude> let f = flip map [1..]
        Prelude> take 10 $ f (+1)
        [2,3,4,5,6,7,8,9,10,11]

You knew this, of course, and I suppose it doesn't scale well to three
or more arguments.

-kzm
-- 
If I haven't seen further, it is by standing in the footprints of giants