Christophe
Weblog
Wiki
Code
Publications
Music
projects
/
paper-els-specializers.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
317a617
)
add one more "interesting" signum method
author
Christophe Rhodes
<csr21@cantab.net>
Fri, 7 Feb 2014 11:52:59 +0000
(11:52 +0000)
committer
Christophe Rhodes
<csr21@cantab.net>
Fri, 7 Feb 2014 11:52:59 +0000
(11:52 +0000)
els-specializers.org
patch
|
blob
|
history
diff --git
a/els-specializers.org
b/els-specializers.org
index 9094ad2a303dc00b544c7e905a7f028e58cd2893..b4e3e79bdc188ddb08c098202be4db8ce6ae96cd 100644
(file)
--- 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)))
(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))))
(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))
(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 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
(defmethod fact ((n (signum -1)))
(error "factorial of negative number: ~D" n))
#+end_src