From ad5a5f9adaf1aa472f2cc563ae475577cca6089a Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Fri, 7 Feb 2014 11:52:59 +0000 Subject: [PATCH] add one more "interesting" signum method --- els-specializers.org | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/els-specializers.org b/els-specializers.org index 9094ad2..b4e3e79 100644 --- a/els-specializers.org +++ b/els-specializers.org @@ -166,6 +166,12 @@ (if (= (%signum s) (%signum g)) ; or EQL? (values t t) (values nil t))) + +;; this method is perhaps interesting enough to talk about? +(defmethod specializer-accepts-generalizer-p ((gf signum-generic-function) (specializer sb-mop:specializer) (thing signum-specializer)) + (specializer-accepts-generalizer-p gf specializer (class-of (%signum thing)))) + + (defmethod specializer-accepts-p ((s signum-specializer) o) (and (realp o) (= (%signum s) (signum o)))) @@ -173,8 +179,8 @@ (defgeneric fact (n) (:generic-function-class signum-generic-function)) -(defmethod fact ((n (signum 1))) (* n (fact (1- n)))) (defmethod fact ((n (signum 0))) 1) +(defmethod fact ((n (signum 1))) (* n (fact (1- n)))) (defmethod fact ((n (signum -1))) (error "factorial of negative number: ~D" n)) #+end_src -- 2.30.2