summaryrefslogtreecommitdiff
path: root/modules/language/python/bool.scm
diff options
context:
space:
mode:
authorStefan Israelsson Tampe <stefan.itampe@gmail.com>2018-05-14 17:59:41 +0200
committerStefan Israelsson Tampe <stefan.itampe@gmail.com>2018-05-14 17:59:41 +0200
commit0a2045050517a2317083bd2ec17bae09e03c4a11 (patch)
treeece44c18b30283919feacce9d166c4cf8cce1d78 /modules/language/python/bool.scm
parent876d5d0fca204adce5335c5486bf6fb3d2188f22 (diff)
further improvements
Diffstat (limited to 'modules/language/python/bool.scm')
-rw-r--r--modules/language/python/bool.scm16
1 files changed, 14 insertions, 2 deletions
diff --git a/modules/language/python/bool.scm b/modules/language/python/bool.scm
index 461dc26..d15c749 100644
--- a/modules/language/python/bool.scm
+++ b/modules/language/python/bool.scm
@@ -14,10 +14,22 @@
#f)
(else x)))
-(define-method (bool (x <integer>)) (not (= x 0)))
+(define-method (bool (x <integer>)) (if (= x 0) #f x))
(define-method (bool (x <p>))
(aif it (ref x '__bool__)
(it)
(next-method)))
-
+
+(define-method (+ (a <boolean>) b)
+ (+ (if a 1 0) b))
+(define-method (+ b (a <boolean>))
+ (+ (if a 1 0) b))
+(define-method (* (a <boolean>) b)
+ (* (if a 1 0) b))
+(define-method (* b (a <boolean>))
+ (* (if a 1 0) b))
+(define-method (- (a <boolean>) b)
+ (- (if a 1 0) b))
+(define-method (- b (a <boolean>))
+ (- b (if a 1 0)))