diff options
author | Bad Diode <bd@badd10de.dev> | 2021-10-13 16:44:17 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2021-10-13 16:44:17 +0200 |
commit | ed1f406102738812fafa5e49ee131fe06c177687 (patch) | |
tree | 0bb648c18b6f96e0f020a9f8e664df330199b51b /examples | |
parent | b8bad3bf5af3261f25780a8cd8b90a659fe29bab (diff) | |
download | bdl-ed1f406102738812fafa5e49ee131fe06c177687.tar.gz bdl-ed1f406102738812fafa5e49ee131fe06c177687.zip |
Add a lot of primitive types
Diffstat (limited to 'examples')
-rw-r--r-- | examples/booleans.bdl | 4 | ||||
-rw-r--r-- | examples/lists.bdl | 2 | ||||
-rw-r--r-- | examples/types.bdl | 21 |
3 files changed, 13 insertions, 14 deletions
diff --git a/examples/booleans.bdl b/examples/booleans.bdl index e38fb1f..0598450 100644 --- a/examples/booleans.bdl +++ b/examples/booleans.bdl | |||
@@ -44,7 +44,7 @@ | |||
44 | (print "(if (or false false) (+ 1 2 3) (+ 7 8 9)) -> ") (if (or false false) (+ 1 2 3) (+ 7 8 9)) | 44 | (print "(if (or false false) (+ 1 2 3) (+ 7 8 9)) -> ") (if (or false false) (+ 1 2 3) (+ 7 8 9)) |
45 | (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)) | 45 | (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)) |
46 | (print "(if true 7) -> ") (if true 7) | 46 | (print "(if true 7) -> ") (if true 7) |
47 | (print "(if false 7) -> ") (if false 7) | 47 | (print "(if false 7) -> ") (if false 7) (newline) |
48 | 48 | ||
49 | ;; Cond. | 49 | ;; Cond. |
50 | (print "(cond ((and true true true) 1) ((or true true false) 2) (else 3)) -> ") | 50 | (print "(cond ((and true true true) 1) ((or true true false) 2) (else 3)) -> ") |
@@ -61,7 +61,7 @@ | |||
61 | (else 3)) | 61 | (else 3)) |
62 | (print "(cond ((and true true true) 1) ((or true true false) 2)) -> ") | 62 | (print "(cond ((and true true true) 1) ((or true true false) 2)) -> ") |
63 | (cond ((and true true false) 1) | 63 | (cond ((and true true false) 1) |
64 | ((or false false false) 2)) | 64 | ((or false false false) 2)) (newline) |
65 | (print "(cond ((and true true true) (+ 1 2 3)) ((or true true false) 2) (else 3)) -> ") | 65 | (print "(cond ((and true true true) (+ 1 2 3)) ((or true true false) 2) (else 3)) -> ") |
66 | (cond ((and true true true) (+ 1 2 3)) | 66 | (cond ((and true true true) (+ 1 2 3)) |
67 | ((or true true false) 2) | 67 | ((or true true false) 2) |
diff --git a/examples/lists.bdl b/examples/lists.bdl index 4a27005..36063d6 100644 --- a/examples/lists.bdl +++ b/examples/lists.bdl | |||
@@ -3,7 +3,7 @@ | |||
3 | ;; | 3 | ;; |
4 | 4 | ||
5 | ;; List function. | 5 | ;; List function. |
6 | (print "(list) -> ") (list) | 6 | (print "(list) -> ") (list) (newline) |
7 | (print "(list 1) -> ") (list 1) | 7 | (print "(list 1) -> ") (list 1) |
8 | (print "(list 1 2) -> ") (list 1 2) | 8 | (print "(list 1 2) -> ") (list 1 2) |
9 | (print "(list 1 2 3) -> ") (list 1 2 3) | 9 | (print "(list 1 2 3) -> ") (list 1 2 3) |
diff --git a/examples/types.bdl b/examples/types.bdl index 43b7be9..36dab7a 100644 --- a/examples/types.bdl +++ b/examples/types.bdl | |||
@@ -12,14 +12,14 @@ | |||
12 | (print "(boolean? (not 1)) -> ") (boolean? (not 1)) | 12 | (print "(boolean? (not 1)) -> ") (boolean? (not 1)) |
13 | 13 | ||
14 | ;; Empty list/null. | 14 | ;; Empty list/null. |
15 | (print "(null? true) -> ") (null? true) | 15 | (print "(nil? true) -> ") (nil? true) |
16 | (print "(null? false) -> ") (null? false) | 16 | (print "(nil? false) -> ") (nil? false) |
17 | (print "(null? 1) -> ") (null? 1) | 17 | (print "(nil? 1) -> ") (nil? 1) |
18 | (print "(null? 5) -> ") (null? 5) | 18 | (print "(nil? 5) -> ") (nil? 5) |
19 | (print "(null? \"string\") -> ") (null? "string") | 19 | (print "(nil? \"string\") -> ") (nil? "string") |
20 | (print "(null? (+ 1 2 3)) -> ") (null? (+ 1 2 3)) | 20 | (print "(nil? (+ 1 2 3)) -> ") (nil? (+ 1 2 3)) |
21 | (print "(null? (not 1)) -> ") (null? (not 1)) | 21 | (print "(nil? (not 1)) -> ") (nil? (not 1)) |
22 | (print "(null? ()) -> ") (null? ()) | 22 | (print "(nil? ()) -> ") (nil? ()) |
23 | 23 | ||
24 | ;; String. | 24 | ;; String. |
25 | (print "(string? true) -> ") (string? true) | 25 | (print "(string? true) -> ") (string? true) |
@@ -40,7 +40,6 @@ | |||
40 | (print "(fixnum? (not 1)) -> ") (fixnum? (not 1)) | 40 | (print "(fixnum? (not 1)) -> ") (fixnum? (not 1)) |
41 | 41 | ||
42 | ;; Symbol | 42 | ;; Symbol |
43 | ;; TODO: We need quotation to test for symbols. | ||
44 | (print "(symbol? true) -> ") (symbol? true) | 43 | (print "(symbol? true) -> ") (symbol? true) |
45 | (print "(symbol? false) -> ") (symbol? false) | 44 | (print "(symbol? false) -> ") (symbol? false) |
46 | (print "(symbol? 1) -> ") (symbol? 1) | 45 | (print "(symbol? 1) -> ") (symbol? 1) |
@@ -48,8 +47,8 @@ | |||
48 | (print "(symbol? \"string\") -> ") (symbol? "string") | 47 | (print "(symbol? \"string\") -> ") (symbol? "string") |
49 | (print "(symbol? (+ 1 2 3)) -> ") (symbol? (+ 1 2 3)) | 48 | (print "(symbol? (+ 1 2 3)) -> ") (symbol? (+ 1 2 3)) |
50 | (print "(symbol? (not 1)) -> ") (symbol? (not 1)) | 49 | (print "(symbol? (not 1)) -> ") (symbol? (not 1)) |
51 | ; (print "(symbol? 'a) -> ") (symbol? 'a) | 50 | (print "(symbol? 'a) -> ") (symbol? 'a) |
52 | ; (print "(symbol? 'c) -> ") (symbol? 'c) | 51 | (print "(symbol? 'c) -> ") (symbol? 'c) |
53 | 52 | ||
54 | ;; Pair. | 53 | ;; Pair. |
55 | (print "(pair? false) -> ") (pair? false) | 54 | (print "(pair? false) -> ") (pair? false) |