about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDarren Bane <dbane@tilde.institute>2021-02-07 00:53:13 +0000
committerDarren Bane <dbane@tilde.institute>2021-02-07 00:53:13 +0000
commit032fb6578034edfef58d8392c4c9b468437b21c8 (patch)
tree603533b7968e4b2a33e97d5ef717733d698b5fff
parentdbb7e6694c351ea0bd78d8405e5fe852f6de04b2 (diff)
downloadlsp-032fb6578034edfef58d8392c4c9b468437b21c8.tar.gz
Fix DBC for eisl
-rw-r--r--dbc2.lsp17
1 files changed, 11 insertions, 6 deletions
diff --git a/dbc2.lsp b/dbc2.lsp
index 477dc38..6d29596 100644
--- a/dbc2.lsp
+++ b/dbc2.lsp
@@ -1,5 +1,8 @@
 (defmacro unless (test :rest body)
-  `(if (not ,test) (progn ,@body)))
+   `(if (not ,test) (progn ,@body)))
+(defmacro assert (test)
+   `(unless ,test
+            (error "assert: value is false." ',test)))
 ;;(defun reduce (function sequence)
 ;;  (let ((res 0))
 ;;    (for ((xs sequence (cdr xs)))
@@ -13,11 +16,13 @@
       (setq res (+ res (car xs))))))
 (defun average-of-absolutes (values)
   (the <list> values)
-  (unless (> (length values) 0)
-    (error "average-of-absolutes requires non-null list" values))
+  ;; (unless (> (length values) 0)
+  ;;   (error "average-of-absolutes requires non-null list" values))
+  (assert (> (length values) 0))
   (let ((res (quotient (sum values) (length values))))
-    (unless (>= res 0)
-      (error "average-of-absolutes must ensure positive result" res))
-    (the <fixnum> res)))
+       ;; (unless (>= res 0)
+       ;;   (error "average-of-absolutes must ensure positive result" res))
+       (assert (>= res 0))
+       (the <fixnum> res)))
 ;; (average-of-absolutes '(1 3))
 ;; (average-of-absolutes '())