?????????????????????
???????????? ???????[ 2013/4/18 11:35:46 ] ????????
??????????????Currying???????????????????????????·????Haskell Curry?????????????????ü?????????????÷????????????????Currying??????????“????”??
??????о??????????????????Currying?????????????Partial Application??????????????????????????????????????????????????????
??????????????????????????????к???????????????????????????????????????????
???????????б???????ж??з??????????????á???C?????У?
int foo(int a?? int b?? int c) {
return a + b + c;
}
int foo23(int a?? int c) {
return foo(a?? 23?? c);
}
????foo23??????????????foo???????????????????b?????????23??
???????????????????????????????????????????????????????????????????Щ???????????
???????磬??Python?????У????????????????
from functools import partial
def foo(a??b??c):
return a + b + c
foo23 = partial(foo?? b=23)
foo23(a = 1?? c = 3) # => 27
??????????????Currying???????????????????????????????????м?????????????????????????????????????first-class?????????????????????????????????????????????????????????????
?????????????????????Javascript??????
var foo = function(a) {
return a * a;
}
??????????????????д????????????????????????????????????????????
var foo = function(a) {
return function(b) {
return a * a + b * b;
}
}
???????????????????(foo(3))(4)??????? foo(3)(4)??
?????????????????????????????????????Щ???????á?????????????foo??????????????????5?????????????var foo5 = foo(5)????OK???????foo5??foo??????????????????????????????к?????????foo?????????????????????(??????????????????????)??
?????????Javascript????????????????
var bar = function(a?? b) {
return a * a + b * b;
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11