Ceylon to Tiny lispTiny lisp, 76
shared void run(){print("(q((x)(s ``process.readLine()else""``(s 0 x))))");}
This produces (after reading a line of input) output like (q((x)(s 5(s 0 x))))
, which evaluates in Tiny Lisp to ((x) (s 5 (s 0 x)))
, a function which takes an argument x
, subtracts it from 0, and subtracts the result from 5. (Yeah, this is how one adds in Tiny Lisp, there is only a subtraction function build in. Of course, one could define an addition function first, but this would be longer.)
You can use it like this as an anonymous function:
((q((x)(s 5(s 0 x)))) 7)
(This will evaluate to 12.)
Or you can give it a name:
(d p5 (q((x)(s 5(s 0 x)))))
(p5 7)
Corrections and Golfing Hints from DLosc, the author of Tiny Lisp.