Question

... partial application (or partial function application) refers to the process of fixing a number of arguments to a function, producing another function of smaller arity.

I would like to find out if there is a specific name for the following: (pseudo-code!)

// Given functions:
def f(a, b) := ...
def g(a, b) := ...
def h(a, b) := ...

// And a construct of the following:
def cc(F, A, B) := F(A, B) // cc calls its argument F with  A and B as parameters

// Then doing Partial Application for cc:
def call_1(F) := cc(F, 42, "answer")
def call_2(F) := cc(F, 7, "lucky")

// And the calling different matching functions this way:
do call_1(f)
do call_1(g)
do call_2(g)
do call_2(h)

Is there a name for this in functional programming? Or is it just partial application where the unbound parameter just happens to be a function

Was it helpful?

Solution

Actually, there's more to things like your call_N functions, beyond just partial application. Two things of note:

  • When you apply call_1 or call_2 to an argument, they can be immediately discarded; everything you do with them will be a tail call.

  • You could write similar functions that don't just apply the argument, but hold onto it for a while; this essentially lets the functions grab hold of their evaluation context, and give techniques for implementing complicated flow control via "jumping back" to previous contexts.

If you take the above two points and run with the concept, you'll eventually end up with continuation-passing style.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top