2009-09-24から1日間の記事一覧

C言語でCurrying

と思ったら既にあった。http://d.hatena.ne.jp/shinichiro_h/20060119 厳密には。 #include <stdio.h> int test(int i, int j) { return i+j; } static int _i; int test1(int j) { return _i+j; } int (*test2(int i))(int) { _i = i; return test1; }厳密には「int </stdio.h>…

C言語でCurrying2

http://d.hatena.ne.jp/shinichiro_h/20060119の手法は引数を積みなおして関数ポインタを呼ぶというもの(だと思う)。 call cを呼んだ直後のスタック …… 100 ret(c) call addを呼んだ直後のスタック …… 100 ret(c) 100 10 ret(add) という感じで。これをtail …