McCarthy 91 function by AndoDaan

i=io.read('*n')
a='M(' b=')' o=a..i..b

function m(n)
  o=o:gsub('%d+',n) o=o:gsub('%-+','-')
  print(o)
  if n>100 then o=o:sub(3,-2) n=n-10  else o=a..o..b n=m(m(n+11)) end
  return n
end
while i~=91 do i=m(i) end 
print(i)

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

download

return to the top page