Skip to content

Instantly share code, notes, and snippets.

@danprince
Last active December 22, 2015 02:59
Show Gist options
  • Save danprince/6407427 to your computer and use it in GitHub Desktop.
Save danprince/6407427 to your computer and use it in GitHub Desktop.
Clojure RPN
(require '[clojure.string :as s])
(defn r[e]
(load-string
(reduce
(fn[x c]
(s/replace x #"([\+\-\*\/] (\(.*\) \d+|\d+ \d+))" "($0)"))
e
(subvec (s/split e #"\d") 1))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment