Skip to content

Instantly share code, notes, and snippets.

@apiology
Created June 3, 2015 13:31
Show Gist options
  • Save apiology/95dac32e0515cf157efa to your computer and use it in GitHub Desktop.
Save apiology/95dac32e0515cf157efa to your computer and use it in GitHub Desktop.
(defn exact-expr [expr]
(cond (coll? expr) (map exact-expr expr)
(number? expr) (rationalize expr)
:else expr))
(defmacro exact [expr]
(exact-expr expr))
(exact (* 2452.45 100))
;=> 245245N
(exact (+ (* 2.3 24) 12))
;=> 336/5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment