(require '[clojure.core.contracts :as contracts])
(defn sqr [n] (* n n))
(sqr 10)
;=> 100
(sqr 0)
;=> 0
(contracts/provide
(sqr "Constraints for squaring"
[x] [number? (not= 0 x) => number? pos?]))
(sqr 10)
;=> 100
(sqr 0)
; java.lang.AssertionError:
; Pre-condition failed: (not= 0 x)
© 2010-2013 Michael Fogus
theme based on a design by Rory Marinich
theme based on a design by Rory Marinich