aboutsummaryrefslogtreecommitdiffstats
path: root/examples/arithmetic.bdl
blob: c3ff2305b57d772a4b9a42f2fc14869d234484f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
;;
;; Basic arithmetic operations.
;;

;; Addition.
(print "(+ 10 100) -> ")   (+ 10 100)
(print "(+ 1 -2 3 4) -> ") (+ 1 -2 3 4)

;; Substraction.
(print "(- 100 75) -> ")   (- 100 75)
(print "(- 10 20 30) -> ") (- 10 20 30)

;; Multiplication.
(print "(* 10 7) -> ")  (* 10 7)
(print "(* -1 66) -> ") (* -1 66)

;; Division.
(print "(/ 45 5) -> ")   (/ 45 5)
(print "(/ 10 5 2) -> ") (/ 10 5 2)

;; Remainder/modulo.
(print "(% 45 5) -> ")     (% 45 5)
(print "(% 45 7) -> ")     (% 45 7)
(print "(% 120 45) -> ")   (% 120 45)
(print "(% 120 45 8) -> ") (% 120 45 8)

;; Nesting operations.
(print "(* 20 (+ 100 (- 50 30) (/ 300 3)) 10) -> ") (* 20 (+ 100 (- 50 30) (/ 300 3)) 10)