From b743e03fc6042e3e2d55cfa0387c092824de64c5 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Sun, 24 Oct 2021 09:52:09 +0200 Subject: Add print/display/newline ops --- examples/arithmetic.bdl | 58 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 13 deletions(-) (limited to 'examples/arithmetic.bdl') diff --git a/examples/arithmetic.bdl b/examples/arithmetic.bdl index c3ff230..c313dbb 100644 --- a/examples/arithmetic.bdl +++ b/examples/arithmetic.bdl @@ -3,26 +3,58 @@ ;; ;; Addition. -(print "(+ 10 100) -> ") (+ 10 100) -(print "(+ 1 -2 3 4) -> ") (+ 1 -2 3 4) +(print "(+ 10 100) -> ") +(display (+ 10 100)) +(newline) + +(print "(+ 1 -2 3 4) -> ") +(display (+ 1 -2 3 4)) +(newline) ;; Substraction. -(print "(- 100 75) -> ") (- 100 75) -(print "(- 10 20 30) -> ") (- 10 20 30) +(print "(- 100 75) -> ") +(display (- 100 75)) +(newline) + +(print "(- 10 20 30) -> ") +(display (- 10 20 30)) +(newline) ;; Multiplication. -(print "(* 10 7) -> ") (* 10 7) -(print "(* -1 66) -> ") (* -1 66) +(print "(* 10 7) -> ") +(display (* 10 7)) +(newline) + +(print "(* -1 66) -> ") +(display (* -1 66)) +(newline) ;; Division. -(print "(/ 45 5) -> ") (/ 45 5) -(print "(/ 10 5 2) -> ") (/ 10 5 2) +(print "(/ 45 5) -> ") +(display (/ 45 5)) +(newline) + +(print "(/ 10 5 2) -> ") +(display (/ 10 5 2)) +(newline) ;; Remainder/modulo. -(print "(% 45 5) -> ") (% 45 5) -(print "(% 45 7) -> ") (% 45 7) -(print "(% 120 45) -> ") (% 120 45) -(print "(% 120 45 8) -> ") (% 120 45 8) +(print "(% 45 5) -> ") +(display (% 45 5)) +(newline) + +(print "(% 45 7) -> ") +(display (% 45 7)) +(newline) + +(print "(% 120 45) -> ") +(display (% 120 45)) +(newline) + +(print "(% 120 45 8) -> ") +(display (% 120 45 8)) +(newline) ;; Nesting operations. -(print "(* 20 (+ 100 (- 50 30) (/ 300 3)) 10) -> ") (* 20 (+ 100 (- 50 30) (/ 300 3)) 10) +(print "(* 20 (+ 100 (- 50 30) (/ 300 3)) 10) -> ") +(display (* 20 (+ 100 (- 50 30) (/ 300 3)) 10)) -- cgit v1.2.1