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
(defn tokenize [expr] | |
(let [to-chars #(clojure.string/split (clojure.string/replace % " " "") #"") | |
is-digit? #(and % (re-find #"^\d+$" %))] | |
(reverse | |
(reduce | |
(fn [[t & ts :as tokens] token] | |
(if (and (is-digit? token) (is-digit? t)) | |
(cons (str t token) ts) | |
(cons token tokens))) | |
'(), (to-chars expr))))) |
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
(defn uuid [] (str (java.util.UUID/randomUUID))) | |
;; => #'user/uuid | |
(defmacro rule [body] | |
(eval `(def ~(symbol (str "rule--" (uuid) "--1")) | |
(fn [] ~body)))) | |
;; => #'user/rule | |
(rule (println "hej")) | |
;; => #'user/rule--a43302b7-a7f3-4648-9a07-0d37554f4ac8--1 |