Skip to content

Instantly share code, notes, and snippets.

@juergenhoetzel
Created August 17, 2010 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save juergenhoetzel/532325 to your computer and use it in GitHub Desktop.
Save juergenhoetzel/532325 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