Advertisement
Guest User

Untitled

a guest
Mar 8th, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (defmacro double-in
  2.   "Specs a 64-bit floating point number. Options:
  3.    :infinite? - whether +/- infinity allowed (default true)
  4.    :NaN?      - whether NaN allowed (default true)
  5.    :min       - minimum value (inclusive, default none)
  6.    :max       - maximum value (inclusive, default none)"
  7.   [& {:keys [infinite? NaN? min max]
  8.     :or {infinite? true NaN? true}
  9.     :as m}]
  10.   `(spec (and c/double?
  11.               ~@(when-not infinite? '[#(not (Double/isInfinite %))])
  12.               ~@(when-not NaN? '[#(not (Double/isNaN %))])
  13.               ~@(when max `[#(<= % ~max)])
  14.               ~@(when min `[#(<= ~min %)]))
  15.          :gen #(gen/double* ~m)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement