Skip to content

Latest commit

 

History

History
55 lines (39 loc) · 1.08 KB

index.org

File metadata and controls

55 lines (39 loc) · 1.08 KB

core.contracts

(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)
source code → tickets →
© 2010-2013 Michael Fogus
theme based on a design by Rory Marinich