diff options
author | Stefan Israelsson Tampe <stefan.itampe@gmail.com> | 2018-05-14 17:59:41 +0200 |
---|---|---|
committer | Stefan Israelsson Tampe <stefan.itampe@gmail.com> | 2018-05-14 17:59:41 +0200 |
commit | 0a2045050517a2317083bd2ec17bae09e03c4a11 (patch) | |
tree | ece44c18b30283919feacce9d166c4cf8cce1d78 /modules/language/python/bool.scm | |
parent | 876d5d0fca204adce5335c5486bf6fb3d2188f22 (diff) |
further improvements
Diffstat (limited to 'modules/language/python/bool.scm')
-rw-r--r-- | modules/language/python/bool.scm | 16 |
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))) |