-
-
Save 9rnsr/2872562 to your computer and use it in GitHub Desktop.
function style
This file contains hidden or 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
import std.stdio; | |
void main() | |
{ | |
T delegate(T) zero(T)(T delegate(T) f) | |
{ | |
return x => x; | |
} | |
T delegate(T) delegate(T delegate(T)) succ(T)(T delegate(T) delegate(T delegate(T)) n) | |
{ | |
return f => x => f(n(f)(x)); | |
} | |
auto n = &zero!uint; | |
foreach (i; 0..10) | |
{ | |
writefln("i = %d: f(0) = %d", i, n(x => x + 1)(0)); | |
assert(n(x => x + 1)(0) == i); | |
n = succ(n); | |
} | |
} |
- bug8198がfixされたので、コメントアウトしていたより短いコードに変更
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
変更点は:
投げる予定投げました