2 ms·
"Implement lambda calculus in languages that are pretty much lambda calculus" How large would implementation be in more usual languages?
by RandomTeaParty 5mo ago
"Implement lambda calculus in languages that are pretty much lambda calculus"
How large would implementation be in more usual languages?
- tromp 5mo agoOne of the smallest implementations is my heavily obfuscated https://www.ioccc.org/2012/tromp/ https://www.ioccc.org/2012/tromp/ : Int L[A],m,b,*D=A, *c,*a=L,C,*U=L,u;s (_){u--&&s(a=*a);} char*B,I,O;S(){b=b --?b:m|read(0,&I,1 )-1;return~I>>b&1; }k(l,u){for(;l<=u; U-L<A?*U++=46^l++[ "-,&,,/.--/,:-,'/" ".-,-,,/.-,*,//..," ]:exit(5));}p(Int*m){ return!*U?*m=S()?U++,!S ()?m[1]=p(++U),2:3:1,p(U) :S()?U+=2:p(U[1]++),U-m;}x( c){k(7*!b,9);*U++=b&&S();c&&x (b);}d(Int*l){--l[1]||d(l[d(*l), *l=B,B=l,2]);}main(e){for(k(10,33 ),a[4]-=m=e-2&7,a[23]=p(U),b=0;;e-2 ?e?e-3?s(D=a),C=a [3],++1[a=a[2]],d( D):c?D=c,c=*D,*D= a,a=D:exit(L[C+1]) :C--<23?C=u+m&1?O =O+O|C&1,9:write(m ||(O=C+28),&O,1)+ 1:(S(),x(0<b++?k(0, 6),U[-5]=96:0)):( D=B?B:calloc(4,X)) ?B=*D,*D=c,c=D,D[ 2]=a,a[++D[1]]++,D [3]=++C+u:exit(6) )e=L[C++],u=L[C];} while a less obfuscated and highly performant implementation https://github.com/tromp/AIT/blob/master/uni.c https://github.com/tromp/AIT/blob/master/uni.c based on combinatory graph reduction takes 446 lines.
- sph 5mo agoEven the unobfuscated version is a work of art. You rarely see such concise and honestly beautiful C code.
- nils-m-holm 5mo agoHere are some starting points for exploration: http://t3x.org/lfn/ http://t3x.org/lfn/ http://t3x.org/klisp/ http://t3x.org/klisp/ http://t3x.org/klisp/22/ http://t3x.org/klisp/22/
- anthk 5mo agoEForth and Subleq can be though too as a systems emerging from axioms (Subleq operations). From twenty macro instructions in EForth it can write the core Subleq code and them bootstrap itself. But the Lisp way it's far more elegant.