Skip to content

Instantly share code, notes, and snippets.

Created September 21, 2011 01:53
Show Gist options
  • Save anonymous/1231000 to your computer and use it in GitHub Desktop.
Save anonymous/1231000 to your computer and use it in GitHub Desktop.
;; amalloy's solution to Universal Computation Engine
;; https://4clojure.com/problem/121
(fn [formula]
(fn [values]
((fn compute [x]
(if (seq? x)
(let [[op & args] x]
(apply ({'+ + '/ / '- - '* *} op)
(map compute args)))
(get values x x)))
formula)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment