Created
July 7, 2012 07:49
-
-
Save fumieval/3065301 to your computer and use it in GitHub Desktop.
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
| { | |
| https://twitter.com/its_out_of_tune/status/221500817616805890 (´・ω・`)すんません。広義の意味で「オブジェクト」と言ったでつ。関数はファーストクラスオブジェクトでしょうか? | |
| https://twitter.com/kuina_tesso/status/221503452851871744 @its_out_of_tune ほぼ、そうであるといえますね。 | |
| ならば、これが動くはずだ。 | |
| } | |
| func fix(f) | |
| {the simplest implementation of fixed point combinator} | |
| func g(arg) | |
| return f(fix(f))(arg) {戻り値の返し方が不明} | |
| end func | |
| return g | |
| end func | |
| func fact_f(self) | |
| func f(n) | |
| if (n = 0) | |
| return 1 | |
| end if | |
| return n * self(n - 1) | |
| end func | |
| return f | |
| end func | |
| func Main() | |
| let Log@WriteLn(fix(fact_f)(5)) | |
| end func |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment