Skip to content

Instantly share code, notes, and snippets.

@yvt
Last active December 27, 2015 01:19
Show Gist options
  • Save yvt/7244581 to your computer and use it in GitHub Desktop.
Save yvt/7244581 to your computer and use it in GitHub Desktop.
Queen カリー化 with 無名関数
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