Church Numerals in ski by Defenestrator

data S=Y S S|A|R|C|O S|I S
n(I t)=1+n t
n C=0
main@m=getLine>>=print.n.(C#).(R#).fst.p>>m
p('`':r)=(y#x,t)where(x,s)=p r;(y,t)=p s
p(c:r)=(q c,r)
q 's'=A;q 'k'=R;q _=C
x#A=O x
y#O x=Y x y
z#Y x y=z#y#(z#x)
x#R=I x
y#I x=x
x#C=x

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page