From c934ceda5e5a8f9d706b1f4e31f343e293e24f6d Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Thu, 28 Oct 2021 13:54:56 +0200 Subject: Fix bug with logic operations --- examples/booleans.bdl | 136 +++++++++++++++++++++++++------------------------- 1 file changed, 68 insertions(+), 68 deletions(-) (limited to 'examples/booleans.bdl') diff --git a/examples/booleans.bdl b/examples/booleans.bdl index 0598450..3d647a6 100644 --- a/examples/booleans.bdl +++ b/examples/booleans.bdl @@ -3,80 +3,80 @@ ;; ;; Not. -(print "(not true) -> ") (not true) -(print "(not false) -> ") (not false) -(print "(not (not true)) -> ") (not (not true)) -(print "(not (not false)) -> ") (not (not false)) -(print "(not 1) -> ") (not 1) -(print "(not (not 1)) -> ") (not (not 1)) -(print "(not \"string\") -> ") (not "string") -(print "(not (not \"string\")) -> ") (not (not "string")) +(print "(not true) -> ") (display (not true))(newline) +(print "(not false) -> ") (display (not false))(newline) +(print "(not (not true)) -> ") (display (not (not true)))(newline) +(print "(not (not false)) -> ") (display (not (not false)))(newline) +(print "(not 1) -> ") (display (not 1))(newline) +(print "(not (not 1)) -> ") (display (not (not 1)))(newline) +(print "(not \"string\") -> ") (display (not "string"))(newline) +(print "(not (not \"string\")) -> ") (display (not (not "string")))(newline) ;; And. -(print "(and 1 \"string\" 4 true) -> ") (and 1 "string" 4 true) -(print "(and true true true) -> ") (and true true true) -(print "(and (+ 1 2 3)) -> ") (and (+ 1 2 3)) -(print "(and false false false) -> ") (and false false false) -(print "(and true false false) -> ") (and true false false) -(print "(and false true false) -> ") (and false true false) -(print "(and false true true) -> ") (and false true true) -(print "(and (not false) true true) -> ") (and (not false) true true) +(print "(and 1 \"string\" 4 true) -> ") (display (and 1 "string" 4 true))(newline) +(print "(and true true true) -> ") (display (and true true true))(newline) +; (print "(and (+ 1 2 3)) -> ") (display (and (+ 1 2 3)))(newline) +(print "(and false false false) -> ") (display (and false false false))(newline) +(print "(and true false false) -> ") (display (and true false false))(newline) +(print "(and false true false) -> ") (display (and false true false))(newline) +(print "(and false true true) -> ") (display (and false true true))(newline) +(print "(and (not false) true true) -> ") (display (and (not false) true true))(newline) ;; Or. -(print "(or 1 \"string\" 4 true) -> ") (or 1 "string" 4 true) -(print "(or false 1) -> ") (or false 1) -(print "(or false \"string\") -> ") (or false "string") -(print "(or false) -> ") (or false) -(print "(or true true true) -> ") (or true true true) -(print "(or false false false) -> ") (or false false false) -(print "(or true false false) -> ") (or true false false) -(print "(or false true false) -> ") (or false true false) -(print "(or false true true) -> ") (or false true true) -(print "(or (not false) true true) -> ") (or (not false) true true) -(print "(or (not true) false) -> ") (or (not true) false) +(print "(or 1 \"string\" 4 true) -> ") (display (or 1 "string" 4 true))(newline) +(print "(or false 1) -> ") (display (or false 1))(newline) +(print "(or false \"string\") -> ") (display (or false "string"))(newline) +; (print "(or false) -> ") (display (or false))(newline) +(print "(or true true true) -> ") (display (or true true true))(newline) +(print "(or false false false) -> ") (display (or false false false))(newline) +(print "(or true false false) -> ") (display (or true false false))(newline) +(print "(or false true false) -> ") (display (or false true false))(newline) +(print "(or false true true) -> ") (display (or false true true))(newline) +(print "(or (not false) true true) -> ") (display (or (not false) true true))(newline) +(print "(or (not true) false) -> ") (display (or (not true) false))(newline) ;; If. -(print "(if true true false) -> ") (if true true false) -(print "(if false true false) -> ") (if false true false) -(print "(if true (+ 1 2 3) 0) -> ") (if true (+ 1 2 3) 0) -(print "(if false (+ 1 2 3) 0) -> ") (if false (+ 1 2 3) 0) -(print "(if (or true false) (+ 1 2 3) (+ 7 8 9)) -> ") (if (or true false) (+ 1 2 3) (+ 7 8 9)) -(print "(if (or false false) (+ 1 2 3) (+ 7 8 9)) -> ") (if (or false false) (+ 1 2 3) (+ 7 8 9)) -(print "(if (or (+ 1 2 3) false) (+ 1 2 3) (+ 7 8 9)) -> ") (if (or (+ 1 2 3) false) (+ 1 2 3) (+ 7 8 9)) -(print "(if true 7) -> ") (if true 7) -(print "(if false 7) -> ") (if false 7) (newline) +(print "(if true true false) -> ") (display (if true true false))(newline) +(print "(if false true false) -> ") (display (if false true false))(newline) +(print "(if true (+ 1 2 3) 0) -> ") (display (if true (+ 1 2 3) 0))(newline) +(print "(if false (+ 1 2 3) 0) -> ") (display (if false (+ 1 2 3) 0))(newline) +(print "(if (or true false) (+ 1 2 3) (+ 7 8 9)) -> ") (display (if (or true false) (+ 1 2 3) (+ 7 8 9)))(newline) +(print "(if (or false false) (+ 1 2 3) (+ 7 8 9)) -> ") (display (if (or false false) (+ 1 2 3) (+ 7 8 9)))(newline) +(print "(if (or (+ 1 2 3) false) (+ 1 2 3) (+ 7 8 9)) -> ") (display (if (or (+ 1 2 3) false) (+ 1 2 3) (+ 7 8 9)))(newline) +(print "(if true 7) -> ") (display (if true 7))(newline) +(print "(if false 7) -> ") (display (if false 7))(newline) -;; Cond. -(print "(cond ((and true true true) 1) ((or true true false) 2) (else 3)) -> ") -(cond ((and true true true) 1) - ((or true true false) 2) - (else 3)) -(print "(cond ((and true true false) 1) ((or true true false) 2) (else 3)) -> ") -(cond ((and true true false) 1) - ((or true true false) 2) - (else 3)) -(print "(cond ((and true true false) 1) ((or false false false) 2) (else 3)) -> ") -(cond ((and true true false) 1) - ((or false false false) 2) - (else 3)) -(print "(cond ((and true true true) 1) ((or true true false) 2)) -> ") -(cond ((and true true false) 1) - ((or false false false) 2)) (newline) -(print "(cond ((and true true true) (+ 1 2 3)) ((or true true false) 2) (else 3)) -> ") -(cond ((and true true true) (+ 1 2 3)) - ((or true true false) 2) - (else 3)) +; ; ;; Cond. +; ; (print "(cond ((and true true true) 1) ((or true true false) 2) (else 3)) -> ") +; ; (cond ((and true true true) 1) +; ; ((or true true false) 2) +; ; (else 3)) +; ; (print "(cond ((and true true false) 1) ((or true true false) 2) (else 3)) -> ") +; ; (cond ((and true true false) 1) +; ; ((or true true false) 2) +; ; (else 3)) +; ; (print "(cond ((and true true false) 1) ((or false false false) 2) (else 3)) -> ") +; ; (cond ((and true true false) 1) +; ; ((or false false false) 2) +; ; (else 3)) +; ; (print "(cond ((and true true true) 1) ((or true true false) 2)) -> ") +; ; (cond ((and true true false) 1) +; ; ((or false false false) 2)) (newline) +; ; (print "(cond ((and true true true) (+ 1 2 3)) ((or true true false) 2) (else 3)) -> ") +; ; (cond ((and true true true) (+ 1 2 3)) +; ; ((or true true false) 2) +; ; (else 3)) ;; Numeric comparisons. -(print "(< 1 2 3) -> ") (< 1 2 3) -(print "(< 3 2 1) -> ") (< 3 2 1) -(print "(> 1 2 3) -> ") (> 1 2 3) -(print "(> 3 2 1) -> ") (> 3 2 1) -(print "(= 1 2 3) -> ") (= 1 2 3) -(print "(= 3 2 1) -> ") (= 3 2 1) -(print "(= 3 3 3) -> ") (= 3 3 3) -(print "(= (+ 1 2) 3 (- 6 3)) -> ") (= (+ 1 2) 3 (- 6 3)) -(print "(< 1 1 3) -> ") (< 1 1 3) -(print "(<= 1 1 3) -> ") (<= 1 1 3) -(print "(> 3 3 1) -> ") (> 3 3 1) -(print "(>= 3 3 1) -> ") (>= 3 3 1) +(print "(< 1 2 3) -> ") (display (< 1 2 3))(newline) +(print "(< 3 2 1) -> ") (display (< 3 2 1))(newline) +(print "(> 1 2 3) -> ") (display (> 1 2 3))(newline) +(print "(> 3 2 1) -> ") (display (> 3 2 1))(newline) +(print "(= 1 2 3) -> ") (display (= 1 2 3))(newline) +(print "(= 3 2 1) -> ") (display (= 3 2 1))(newline) +(print "(= 3 3 3) -> ") (display (= 3 3 3))(newline) +(print "(= (+ 1 2) 3 (- 6 3)) -> ") (display (= (+ 1 2) 3 (- 6 3)))(newline) +(print "(< 1 1 3) -> ") (display (< 1 1 3))(newline) +(print "(<= 1 1 3) -> ") (display (<= 1 1 3))(newline) +(print "(> 3 3 1) -> ") (display (> 3 3 1))(newline) +(print "(>= 3 3 1) -> ") (display (>= 3 3 1))(newline) -- cgit v1.2.1