While defining contracts local to the constrained function is nice (see defconstrainedfn for more information), very often you will find yourself in possession of an existing function that is not constrained:
(sqr 0);=> 0
(provide-contracts[sqr "Constraints for squaring"[x] [number? (not= 0 x) => number? pos?]])(sqr 0); java.lang.AssertionError:; Assert failed: (not= 0 n)
(defcontract sqr-contract"Defines the constraints on squaring."[n] [number? (not= 0 n) => pos? number?])(sqr 0);=> 0(provide-contracts[sqr "Apply the contract for squaring"sqr-contract])(sqr 0); java.lang.AssertionError:; Assert failed: (not= 0 n)
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close