Last active
December 22, 2015 02:59
-
-
Save danprince/6407427 to your computer and use it in GitHub Desktop.
Clojure RPN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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