(require 'grass) (grass-plant-code '( (abs print (n) ((app n succ . n_succ) (app n_succ w . ch) (app out ch) )) (abs id (n) ()) (abs mkidprint (f n) ((app print n) (app id f) )) (abs W (x y) ((app x x . xx) (app xx y) ;; W = λxy.xxy )) (abs X (f x) ((app W x . Wx) ;; (λxy.xxy)x -> λy.xxy (app f Wx) ;; X = λfx.f(λy.xxy) )) (abs Y (f) ;; Y combinator ((app X f . Xf) ;; (λfx.f(λy.xxy))f -> λx.f(λy.xxy) (app Xf Xf) ;; Y = λf.(λx.f(λy.xxy))(λx.f(λy.xxy)) )) (abs idprint (n) ((app Y mkidprint . Y_mkidprint) (app Y_mkidprint n) )) (abs <2> (f x) ((app f x . fx) (app f fx) ;; f (f x) )) (app <2> <2> . <4>) ;; 2^2 = 4 (abs inc (n f x) ((app n f . nf) (app nf x . nfx) (app f nfx) ;; f (n f x) )) (app inc <2> . <3>) (app <2> <3> . <9>) ;; 3^2 = 9 (app <4> inc . <4>inc) (app <4>inc <9> . <13>) (app inc <13> . <14>) (app inc <14> . <15>) (abs <2> (f x) ((app f x . fx) (app f fx) ;; f (f x) )) (app <2> <15> . <225>) ;; 15^2 = 225 (app <2> <14> . <196>) ;; 14^2 = 196 (app <2> <13> . <169>) ;; 13^2 = 169 ; SPC (app <3> <4>inc . <12>inc) (app <12>inc <169> . <181>) ;; , (app <12>inc <196> . <208>) (app <12>inc <225> . <237>) ;; d (abs inc (n f x) ((app n f . nf) (app nf x . nfx) (app f nfx) ;; f (n f x) )) (app inc <169> . <170>) ;; ! (app inc <208> . <209>) ;; H (app inc <237> . <238>) ;; e (app inc <238> . <239>) (app <3> inc . <3>inc) (app <3>inc <239> . <242>) (app <3>inc <242> . <245>) ;; l (app <3>inc <245> . <248>) ;; o (app <3>inc <248> . <251>) ;; r (abs print_Hello (dummy) ((app idprint <209>) ;; H (app 1 <238>) ;; e (app 1 <245>) ;; l (app 1 <245>) ;; l (app 1 <248>) ;; o (app 1 <181>) ;; , (app 1 <169>) ;; SPC )) (abs <0> (f x) ;; w ()) (app print_Hello 1) ;; (1 is dummy argument) (app 1 <0>) ;; w (app 1 <248>) ;; o (app 1 <251>) ;; r (app 1 <245>) ;; l (app 1 <237>) ;; d (app 1 <170>) ;; ! (abs main (n) ()) ;; (Null function to avoid error) ))