blob: 48f1d6feec8e4988e9eff7c88f4c2578208d4a9b (
plain) (
tree)
|
|
;; 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 '())
|