1

...部分应用(或部分函数应用)是指将多个参数固定到函数的过程,从而产生另一个较小的函数。

我想知道以下是否有特定名称:(伪代码!

// 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)

在函数式编程中有这个名字吗?或者它只是部分应用程序,其中未绑定的参数恰好是一个函数

4

1 回答 1

1

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.

于 2011-08-12T06:51:23.347 回答