Skip to content

Instantly share code, notes, and snippets.

@fogus
Forked from juergenhoetzel/defunits-of.clj
Created August 27, 2010 01:41
Show Gist options
  • Save fogus/552611 to your computer and use it in GitHub Desktop.
Save fogus/552611 to your computer and use it in GitHub Desktop.
(defmacro defunits-of [quantity base-unit & units]
(let [magnitude (gensym)
unit (gensym)
conversions (apply hash-map base-unit 1 units)]
`(defmacro ~(symbol (str "unit-of-" quantity))
[~magnitude ~unit]
`(* ~~magnitude
~(relative-units ~unit ~conversions)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment