LambdaPython
Jump to navigation
Jump to search
LambdaPython is Python, but if your program includes def
, it raises a syntax error (that means you must use built-in functions or lambda functions instead of normal ones, thus the name). It is create by User:None1 and inspired by UnnumericJS which is inspired by MangularJS.
Examples
Most programs are the same (as Python), but here is an example that computes the n-th fibonacci number using recursion (reads n and outputs the n-th fibonacci number):
exec('\x64\x65\x66\x20\x66\x69\x62\x28\x6e\x29\x3a\x0a\x09\x69\x66\x20\x6e\x3d\x3d\x30\x3a\x0a\x09\x09\x72\x65\x74\x75\x72\x6e\x20\x30\x0a\x09\x69\x66\x20\x6e\x3d\x3d\x31\x3a\x0a\x09\x09\x72\x65\x74\x75\x72\x6e\x20\x31\x0a\x09\x72\x65\x74\x75\x72\x6e\x28\x66\x69\x62\x28\x6e\x2d\x31\x29\x2b\x66\x69\x62\x28\x6e\x2d\x32\x29\x29\x0a\x70\x72\x69\x6e\x74\x28\x66\x69\x62\x28\x69\x6e\x74\x28\x69\x6e\x70\x75\x74\x28\x29\x29\x29\x29')
Athough it uses recursion, it does not include def
, so it is still allowed.
Interpreter in Python
import sys code=sys.stdin.read() if 'def' in code: raise Exception('Syntax error') else: exec(code)
Self interpreter
import sys code=sys.stdin.read() if '\x64\x65\x66' in code: raise Exception('Syntax error') else: exec(code)
This is also an interpreter in Python.
Turing completeness
We can use exec()
and the hexadecimal escape to run any Python code, so it is Turing complete.