rply parser + historical implementation

This commit is contained in:
Loic Nageleisen 2013-10-03 07:58:22 +02:00
parent 93796389e0
commit 12da94d927
4 changed files with 169 additions and 0 deletions

13
factorial.py Normal file
View file

@ -0,0 +1,13 @@
from lysssp import _eval, globs
_eval(['setq', 'factorial', ['lambda', ['x'],
['cond', [
[ ['equal?', 'x', 0], 1 ],
[ True, [ '*', 'x', ['factorial', ['-', 'x', 1]]]]]]]], globs)
def test():
print _eval(['factorial', 10], globs)
import timeit
print timeit.Timer(test).timeit(1)