部分应用是一种更广泛的技巧,它与局部套用类似,但是生成的函数并不限于单函数。
Partial application is a broader technique that resembles currying but does not restrict the resulting function to a single argument.
当然,Scala支持局部套用,如清单8展示的 Scala文档的部分片段所示
Of course, Scala supports currying, as illustrated by the snippet from the Scala documentation shown in Listing 8
要使用volume作为代码块的构建块并返回线段的长度,可以执行部分应用或局部套用。
To use volume as a building block for a code block that returns the length of a line segment, I can perform either partial application or currying.
这两者之间的差别非常微小,最终结果也是相同的,但是如果您在一名函数编程人员的面前混用局部套用和部分应用,那么他一定会纠正您的说法。
The difference is subtle, and the end result is the same, but if you use the terms currying and partial application interchangeably within earshot of a functional programmer, count on being corrected.
这两者之间的差别非常微小,最终结果也是相同的,但是如果您在一名函数编程人员的面前混用局部套用和部分应用,那么他一定会纠正您的说法。
The difference is subtle, and the end result is the same, but if you use the terms currying and partial application interchangeably within earshot of a functional programmer, count on being corrected.
应用推荐