スタック
さらに
#define cons (S (S (K S) (S (K K) (S (K S) (S (K (S I)) K)))) (K K)) #define car (S (K (S I)) K K) #define cdr (S (K (S I)) K (K I)) void* STACK = NULL; combinator push(a) { return STACK=cons(a)(STACK); } combinator pop(a) { combinator ret = car(STACK); STACK=cdr(STACK); return ret; } int i; for(i=0;i<100;i++) push(i); for(i=0;i<100;i++) printf("%d,",pop());
として stack の実装完了。
http://d.hatena.ne.jp/yoira/20051023#p1
http://d.hatena.ne.jp/succeed/20051029#1130560944
あ、継続のスタックをここに貼らせてくれるとうれしいなあ。