aboutsummaryrefslogtreecommitdiffstats
path: root/examples/arithmetic.bdl
blob: c313dbb92753cef89bf36165d74ab4e0b18321c7 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
;;
;; Basic arithmetic operations.
;;

;; Addition.
(print "(+ 10 100) -> ")
(display (+ 10 100))
(newline)

(print "(+ 1 -2 3 4) -> ")
(display (+ 1 -2 3 4))
(newline)

;; Substraction.
(print "(- 100 75) -> ")
(display (- 100 75))
(newline)

(print "(- 10 20 30) -> ")
(display (- 10 20 30))
(newline)

;; Multiplication.
(print "(* 10 7) -> ")
(display (* 10 7))
(newline)

(print "(* -1 66) -> ")
(display (* -1 66))
(newline)

;; Division.
(print "(/ 45 5) -> ")
(display (/ 45 5))
(newline)

(print "(/ 10 5 2) -> ")
(display (/ 10 5 2))
(newline)

;; Remainder/modulo.
(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) -> ")
(display (* 20 (+ 100 (- 50 30) (/ 300 3)) 10))