Adding in a bit of voodoo.
This commit is contained in:
parent
8309210ac9
commit
55062b3845
@ -297,8 +297,8 @@ class HyASTCompiler(object):
|
|||||||
if fn in _compile_table:
|
if fn in _compile_table:
|
||||||
return _compile_table[fn](self, expression)
|
return _compile_table[fn](self, expression)
|
||||||
|
|
||||||
if expression[0].startswith("."):
|
if expression[0].startswith("."):
|
||||||
return self.compile_dotted_expression(expression)
|
return self.compile_dotted_expression(expression)
|
||||||
|
|
||||||
return ast.Call(func=self.compile(fn),
|
return ast.Call(func=self.compile(fn),
|
||||||
args=[self.compile(x) for x in expression[1:]],
|
args=[self.compile(x) for x in expression[1:]],
|
||||||
|
@ -13,10 +13,27 @@
|
|||||||
<div class = 'focus' >
|
<div class = 'focus' >
|
||||||
<div class = 'repl' >
|
<div class = 'repl' >
|
||||||
<textarea id = 'repl-input' class = 'repl-pane repl-left' >
|
<textarea id = 'repl-input' class = 'repl-pane repl-left' >
|
||||||
(defn square [x]
|
; Very much a knockoff (straight port) of Dan Gulotta's 2013 MIT Mystery Hunt
|
||||||
(* x x))
|
; puzzle "The Halting Problem".
|
||||||
|
|
||||||
(print (square 4))
|
|
||||||
|
(defn evaluate [f] ((f (lambda [x] (+ x 1))) 0))
|
||||||
|
|
||||||
|
(defn successor [n] (lambda [f] (lambda [x] (f ((n f) x)))))
|
||||||
|
(defn plus [m n] ((n successor) m))
|
||||||
|
(defn exponent [m n] (n m))
|
||||||
|
(defn zero [f] (lambda [x] x))
|
||||||
|
(defn one [f] (lambda [x] (f x)))
|
||||||
|
|
||||||
|
(defn predecessor [n] (lambda [f] (lambda [x]
|
||||||
|
(((n (lambda [g] (lambda [h] (h (g f))))) (lambda [y] x)) (lambda [z] z)))))
|
||||||
|
|
||||||
|
(defn subtract [m n] ((m predecessor) n))
|
||||||
|
|
||||||
|
(def two (plus one one))
|
||||||
|
(def three (plus two one))
|
||||||
|
|
||||||
|
(print (evaluate (exponent three three)))
|
||||||
</textarea>
|
</textarea>
|
||||||
<pre id = 'repl-output' class = 'repl-pane repl-right' ></pre>
|
<pre id = 'repl-output' class = 'repl-pane repl-right' ></pre>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user