Skip to content

Instantly share code, notes, and snippets.

Created June 6, 2012 00:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2878990 to your computer and use it in GitHub Desktop.
Save anonymous/2878990 to your computer and use it in GitHub Desktop.
;; ariarule's solution to Universal Computation Engine
;; https://4clojure.com/problem/121
(fn uce [formula]
(fn [z]
(letfn [
(replacer [x]
(if (list? x)
(apply (get {'/ / '+ + '- - '* *} (first x))
(map replacer (rest x)))
(if (number? x)
x
(get z x))))]
(replacer formula))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment