blob: 57e04e565e9daab53650a2f196cb6b282a741c0c (
plain) (
tree)
|
|
;; Ported from https://rosettacode.org/wiki/Assertions_in_design_by_contract#Eiffel
;; Arguably not *quite* design-by-contract, but very close in vanilla CL
;;
;; NB: This has non-essential complexity compared to the ISLisp version.
(defun average-of-absolutes (values)
(declare (list values))
(assert (> (length values) 0))
(let ((res (/ (reduce #'+ (mapcar #'abs values)) (length values))))
(assert (>= res 0))
(the fixnum res)))
;; (average-of-absolutes '(1 3))
;; (average-of-absolutes '())
|