-
Notifications
You must be signed in to change notification settings - Fork 15
provide
Joshua Mendoza edited this page Jul 6, 2014
·
3 revisions
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[sqr "Constraints for squaring"[x] [number? (not= 0 x) => number? pos?]])(sqr 0); java.lang.AssertionError:; Assert failed: (not= 0 n)
(def sqr-contract(contract sqr-constraint"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)