about summary refs log blame commit diff stats
path: root/dbc.lsp
blob: 48f1d6feec8e4988e9eff7c88f4c2578208d4a9b (plain) (tree)
1
2
3
4
5
6
7
8
9




                                                                                   

                                                    
              
                               



                                                                      
;; Ported from https://rosettacode.org/wiki/Assertions_in_design_by_contract#Eiffel
(require "contract")
;; (set-dynamic *use-contract* nil)
(defcontract average-of-absolutes (values)
   (:in ()
	(assure <list> values)
	(> (length values) 0))		; Redundant?
   (:out (res)
	 (assure <integer> res)
	 (>= res 0))
   (quotient (reduce #'+ (map '<list> #'abs values)) (length values)))
;; (average-of-absolutes '(1 3))
;; (average-of-absolutes '())