Last active
December 27, 2015 01:19
-
-
Save yvt/7244581 to your computer and use it in GitHub Desktop.
Queen カリー化 with 無名関数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func Times(n: int, f: func<(int)>) | |
for i(1, n) | |
f(i) | |
end for | |
end func | |
func Sum(f: func<(int):int>, n: int): int | |
var v:: 0 | |
Times(n, func(i: int) | |
v :+ f(i) | |
end func) | |
return v | |
end func | |
func SumCurry(f: func<(int):int>): func<(int):int> | |
return func(n: int): int | |
var v:: 0 | |
Times(n, func(i: int) | |
v :+ f(i) | |
end func) | |
return v | |
end func | |
end func | |
func AppMain() | |
Dbg@Log(Sum(func(i: int): int | |
return i | |
end func, 100).ToStr()) | |
Dbg@Log(SumCurry(func(i: int): int | |
return i | |
end func)(100).ToStr()) | |
Q@Stop() | |
end func |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment