我正在学习函数式编程。当我读到关于FP的lambda部分介绍时,我想到了一个问题。方案语言中的lambda语法
In Scheme the syntax for anonymous functions is the following one:
(lambda (arg1...argn) body)
...
We can now easily define the compose function
(define (compose f g)
(lambda (x) (f (g x))))
我努力去理解有关x
,它不是在compose
函数定义的参数列表。那么x
如何传入?
另外,假设我们有功能g1
采取参数y
,z
,如何拨打compose
? compose (f1 g1) y z
?如果是这样,那么它不仅需要两个函数的参数,还需要来自g1的参数。我很困惑。
'x'是结果组成的参数。假设你有函数'f1'和'g1'和参数'x1',那么你可以像这样调用'((compose f1 g1)x1)'。 – PetSerAl