Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 46 lines (31 sloc) 0.758 kb

core.contracts

(ns my.awesome.lib
  (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)
Something went wrong with that request. Please try again.