nydp 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +44 -0
  3. data/lib/lisp/core-010-precompile.nydp +13 -16
  4. data/lib/lisp/core-012-utils.nydp +21 -6
  5. data/lib/lisp/core-015-documentation.nydp +58 -24
  6. data/lib/lisp/core-017-builtin-dox.nydp +49 -42
  7. data/lib/lisp/core-020-utils.nydp +5 -5
  8. data/lib/lisp/core-030-syntax.nydp +191 -96
  9. data/lib/lisp/core-035-flow-control.nydp +41 -14
  10. data/lib/lisp/core-037-list-utils.nydp +36 -14
  11. data/lib/lisp/core-039-module.nydp +24 -0
  12. data/lib/lisp/core-040-utils.nydp +51 -23
  13. data/lib/lisp/core-041-string-utils.nydp +37 -9
  14. data/lib/lisp/core-042-date-utils.nydp +21 -1
  15. data/lib/lisp/core-043-list-utils.nydp +99 -73
  16. data/lib/lisp/core-045-dox-utils.nydp +5 -0
  17. data/lib/lisp/core-070-prefix-list.nydp +1 -1
  18. data/lib/lisp/core-080-pretty-print.nydp +57 -17
  19. data/lib/lisp/core-090-hook.nydp +35 -1
  20. data/lib/lisp/core-100-utils.nydp +110 -15
  21. data/lib/lisp/core-110-hash-utils.nydp +61 -0
  22. data/lib/lisp/core-120-settings.nydp +46 -0
  23. data/lib/lisp/core-130-validations.nydp +51 -0
  24. data/lib/lisp/{core-060-benchmarking.nydp → core-900-benchmarking.nydp} +107 -19
  25. data/lib/lisp/tests/accum-examples.nydp +28 -1
  26. data/lib/lisp/tests/aif-examples.nydp +8 -3
  27. data/lib/lisp/tests/andify-examples.nydp +7 -0
  28. data/lib/lisp/tests/at-syntax-examples.nydp +17 -0
  29. data/lib/lisp/tests/best-examples.nydp +9 -0
  30. data/lib/lisp/tests/builtin-tests.nydp +19 -0
  31. data/lib/lisp/tests/case-examples.nydp +14 -0
  32. data/lib/lisp/tests/cdr-set-examples.nydp +6 -0
  33. data/lib/lisp/tests/date-examples.nydp +56 -1
  34. data/lib/lisp/tests/destructuring-examples.nydp +46 -14
  35. data/lib/lisp/tests/detect-examples.nydp +12 -0
  36. data/lib/lisp/tests/dp-examples.nydp +24 -0
  37. data/lib/lisp/tests/each-tests.nydp +5 -0
  38. data/lib/lisp/tests/empty-examples.nydp +1 -1
  39. data/lib/lisp/tests/error-tests.nydp +4 -4
  40. data/lib/lisp/tests/explain-mac-examples.nydp +1 -1
  41. data/lib/lisp/tests/filter-forms-examples.nydp +15 -0
  42. data/lib/lisp/tests/foundation-test.nydp +12 -0
  43. data/lib/lisp/tests/hash-examples.nydp +26 -2
  44. data/lib/lisp/tests/list-grep-examples.nydp +40 -0
  45. data/lib/lisp/tests/list-tests.nydp +58 -1
  46. data/lib/lisp/tests/map-hash-examples.nydp +11 -0
  47. data/lib/lisp/tests/module-examples.nydp +10 -0
  48. data/lib/lisp/tests/multi-assign-examples.nydp +6 -0
  49. data/lib/lisp/tests/parser-tests.nydp +25 -0
  50. data/lib/lisp/tests/pretty-print-tests.nydp +17 -14
  51. data/lib/lisp/tests/set-difference-examples.nydp +8 -0
  52. data/lib/lisp/tests/set-intersection-examples.nydp +16 -0
  53. data/lib/lisp/tests/set-union-examples.nydp +8 -0
  54. data/lib/lisp/tests/settings-examples.nydp +40 -0
  55. data/lib/lisp/tests/sort-examples.nydp +8 -0
  56. data/lib/lisp/tests/string-tests.nydp +65 -1
  57. data/lib/lisp/tests/syntax-tests.nydp +5 -1
  58. data/lib/lisp/tests/to-integer-examples.nydp +16 -0
  59. data/lib/lisp/tests/validation-examples.nydp +15 -0
  60. data/lib/lisp/tests/zap-examples.nydp +12 -0
  61. data/lib/nydp.rb +13 -7
  62. data/lib/nydp/assignment.rb +10 -3
  63. data/lib/nydp/builtin.rb +1 -1
  64. data/lib/nydp/builtin/abs.rb +8 -0
  65. data/lib/nydp/builtin/cdr_set.rb +1 -6
  66. data/lib/nydp/builtin/date.rb +15 -1
  67. data/lib/nydp/builtin/error.rb +1 -1
  68. data/lib/nydp/builtin/handle_error.rb +1 -1
  69. data/lib/nydp/builtin/hash.rb +27 -45
  70. data/lib/nydp/builtin/inspect.rb +1 -1
  71. data/lib/nydp/builtin/plus.rb +10 -2
  72. data/lib/nydp/builtin/random_string.rb +2 -2
  73. data/lib/nydp/builtin/{car.rb → regexp.rb} +2 -2
  74. data/lib/nydp/builtin/ruby_wrap.rb +72 -0
  75. data/lib/nydp/builtin/string_match.rb +2 -2
  76. data/lib/nydp/builtin/string_pad_left.rb +7 -0
  77. data/lib/nydp/builtin/string_pad_right.rb +7 -0
  78. data/lib/nydp/builtin/string_replace.rb +1 -1
  79. data/lib/nydp/builtin/string_split.rb +4 -3
  80. data/lib/nydp/builtin/to_integer.rb +23 -0
  81. data/lib/nydp/builtin/to_string.rb +2 -9
  82. data/lib/nydp/builtin/type_of.rb +9 -6
  83. data/lib/nydp/closure.rb +0 -3
  84. data/lib/nydp/cond.rb +23 -1
  85. data/lib/nydp/context_symbol.rb +14 -6
  86. data/lib/nydp/core.rb +36 -28
  87. data/lib/nydp/core_ext.rb +54 -0
  88. data/lib/nydp/date.rb +37 -31
  89. data/lib/nydp/function_invocation.rb +34 -26
  90. data/lib/nydp/hash.rb +5 -6
  91. data/lib/nydp/helper.rb +41 -25
  92. data/lib/nydp/interpreted_function.rb +68 -40
  93. data/lib/nydp/literal.rb +1 -1
  94. data/lib/nydp/pair.rb +22 -5
  95. data/lib/nydp/parser.rb +11 -7
  96. data/lib/nydp/string_atom.rb +16 -22
  97. data/lib/nydp/symbol.rb +40 -27
  98. data/lib/nydp/symbol_lookup.rb +7 -7
  99. data/lib/nydp/tokeniser.rb +2 -2
  100. data/lib/nydp/truth.rb +17 -10
  101. data/lib/nydp/version.rb +1 -1
  102. data/lib/nydp/vm.rb +7 -2
  103. data/nydp.gemspec +2 -4
  104. data/spec/date_spec.rb +115 -22
  105. data/spec/embedded_spec.rb +12 -12
  106. data/spec/foreign_hash_spec.rb +14 -2
  107. data/spec/hash_non_hash_behaviour_spec.rb +7 -7
  108. data/spec/hash_spec.rb +24 -2
  109. data/spec/nydp_spec.rb +14 -2
  110. data/spec/pair_spec.rb +3 -1
  111. data/spec/parser_spec.rb +31 -20
  112. data/spec/rand_spec.rb +3 -3
  113. data/spec/spec_helper.rb +13 -1
  114. data/spec/symbol_spec.rb +31 -0
  115. data/spec/time_spec.rb +1 -1
  116. metadata +31 -38
  117. data/lib/nydp/builtin/cdr.rb +0 -7
  118. data/lib/nydp/builtin/cons.rb +0 -9
@@ -26,6 +26,18 @@
26
26
  "zz")
27
27
  nil)
28
28
 
29
+ ("empty list"
30
+ (detect present? nil)
31
+ nil)
32
+
33
+ ("present? for list of empty things"
34
+ (detect present? (list "" nil {} ()))
35
+ nil)
36
+
37
+ ("present? for mostly empty things"
38
+ (detect present? (list "" nil 42 {} ()))
39
+ 42)
40
+
29
41
  ("nil for nil"
30
42
  (detect nil nil)
31
43
  nil)
@@ -0,0 +1,24 @@
1
+ (examples-for dp
2
+ ("returns nil for nil"
3
+ (dp)
4
+ nil)
5
+
6
+ ("returns nil when everything is empty"
7
+ (dp "" nil {} ())
8
+ nil)
9
+
10
+ ("returns the first item if not empty"
11
+ (dp 'a "" {} ())
12
+ a)
13
+
14
+ ("returns the second item if not empty"
15
+ (dp "" 'b "" {} ())
16
+ b)
17
+
18
+ ("returns the third item if not empty"
19
+ (dp "" {} 'c "" {} ())
20
+ c)
21
+
22
+ ("returns the last item if not empty"
23
+ (dp "" {} () 'd)
24
+ d))
@@ -2,3 +2,8 @@
2
2
  ("iterates over each item in list"
3
3
  (let acc 0 (each x '(1 2 3 4) (assign acc (+ x acc))) acc)
4
4
  10))
5
+
6
+ (examples-for each-with-index
7
+ ("iterates over each item in list"
8
+ (returnlet acc nil (each-with-index i x '(a b c d) (push (list i x) acc)))
9
+ ( (3 d) (2 c) (1 b) (0 a) )))
@@ -18,7 +18,7 @@
18
18
  ("nonzero" (present? "foo-bar") t)
19
19
  ("zero" (present? "") nil)
20
20
  ("blank" (present? " ") t)
21
- ("nil is t" (present? nil) nil)
21
+ ("nil is nil" (present? nil) nil)
22
22
  ("sym is t" (present? 'abc) t)
23
23
  ("number is t" (present? 234) t)
24
24
 
@@ -20,10 +20,10 @@
20
20
  (on-err (error "bar")
21
21
  (on-err (error "toto")
22
22
  (error "primum errorum")))))
23
- "\"foo\"
24
- \"bar\"
25
- \"toto\"
26
- \"primum errorum\"")
23
+ "foo
24
+ bar
25
+ toto
26
+ primum errorum")
27
27
 
28
28
  ("handles errors but any ensuring clause gets called first"
29
29
  (with (x nil y nil)
@@ -13,7 +13,7 @@
13
13
 
14
14
  ("expands thrice for n = 3"
15
15
  (explain-mac 3 '(afn (a) (let b (+ 2 a) (* b b))))
16
- (with (self nil) (assign self (fn (a) (let b (+ 2 a) (* b b))))))
16
+ ((fun (self) (assign self (fn (a) (let b (+ 2 a) (* b b))))) nil))
17
17
 
18
18
  ("expands four times for n = 4"
19
19
  (explain-mac 4 '(afn (a) (let b (+ 2 a) (* b b))))
@@ -1,3 +1,18 @@
1
+ (examples-for filter-remove
2
+ ("removes (memoise) from a list of forms"
3
+ (filter-remove 'memoise '((trace)
4
+ ;; this is a comment
5
+ (memoise)
6
+ (let x a
7
+ (+ x b)
8
+ (bingo dingbat))))
9
+ (((memoise))
10
+ ((trace)
11
+ (comment "this is a comment")
12
+ (let x a
13
+ (+ x b)
14
+ (bingo dingbat))))))
15
+
1
16
  (examples-for filter-forms
2
17
  ("groups forms by their 'car if the 'car is a key in the given hash"
3
18
  (let ff (filter-forms { car nil comment nil mac nil }
@@ -169,3 +169,15 @@
169
169
  ("argument default value is nil"
170
170
  ( (fn (x y z) (list x y (car z))) 'a 'b )
171
171
  (a b nil)))
172
+
173
+ (examples-for do
174
+ ("executes its content"
175
+ (let premesolithic 3
176
+ (do
177
+ (assign premesolithic (* premesolithic 4))
178
+ (let jurassic 17
179
+ (do
180
+ (= jurassic (+ jurassic premesolithic))
181
+ (= premesolithic (+ jurassic premesolithic))
182
+ (* premesolithic 2)))))
183
+ 82))
@@ -1,3 +1,20 @@
1
+ (examples-for hash-replace-keys
2
+ ("changes strings to symbols"
3
+ (let h (hash-replace-keys λk(sym k) { "a" 1 "b" 2 "c" 3 })
4
+ (list (hash-keys h) (hash-values h)))
5
+ ((a b c) (1 2 3)))
6
+
7
+ ("appends a character to keys"
8
+ (let h (hash-replace-keys λk(string-pieces k "!") { "a" 1 "b" 2 "c" 3 })
9
+ (list (hash-keys h) (hash-values h)))
10
+ (("a!" "b!" "c!") (1 2 3))))
11
+
12
+ (examples-for hash
13
+ ("builds a hash"
14
+ (let h (hash "a" 1 'b 2 '(x y) 3)
15
+ (list (hash-keys h) (hash-values h)))
16
+ (("a" b (x y)) (1 2 3))))
17
+
1
18
  (examples-for hash-values
2
19
  ("returns the list of values of the given hash"
3
20
  (hash-values { a 1 b 2 c 'c d "hello" })
@@ -10,6 +27,12 @@
10
27
  (" t for a hash" (hash? {a 1 b 2}) t )
11
28
  ("nil for a symbol" (hash? 'foo) nil))
12
29
 
30
+ (examples-for hash-slice
31
+ ("returns a new hash containing only the specified keys"
32
+ (let h (hash-slice { a 1 b 2 c 3 d 4 } '(a b e f))
33
+ (list (hash-keys h) (hash-values h)))
34
+ ((a b) (1 2))))
35
+
13
36
  (examples-for hash-merge
14
37
  ("merge with symbol keys"
15
38
  (let h (hash-merge { a 1 b 2 c 3 } { a 99 c 98 d 97 })
@@ -28,8 +51,9 @@
28
51
  ("returns nil for a symbol" (hash-keys 'lipstick) nil)
29
52
 
30
53
  ("returns date operations"
31
- (hash-keys (date 2015 11 18))
32
- (beginning_of_month
54
+ (sort:hash-keys (date 2015 11 18))
55
+ (age
56
+ beginning_of_month
33
57
  beginning_of_week
34
58
  beginning_of_year
35
59
  day
@@ -0,0 +1,40 @@
1
+ (examples-for list/grep
2
+ ("it finds strings"
3
+ (list/grep
4
+ string?
5
+ (list 'foo "bar" '(a b "c d" e) { ignores "hash elements" }))
6
+ ("bar" "c d"))
7
+
8
+ ("it finds items whose car is carryon"
9
+ (list/grep
10
+ λf(caris 'carryon f)
11
+ '(foo
12
+ (carryon 1 2 3 42)
13
+ (bar (40 41 42 (carryon 43 (carryon 42) 41)))
14
+ 42
15
+ 99))
16
+ ((carryon 1 2 3 42)
17
+ (carryon 43 (carryon 42) 41)
18
+ (carryon 42)))
19
+
20
+ ("it finds items of length 3"
21
+ (list/grep
22
+ λf(eq? 3 (len f))
23
+ '(foo
24
+ (2 3 42)
25
+ (bar (40 41 42) (43 (x y z) 41))
26
+ 42
27
+ 99))
28
+ ((2 3 42)
29
+ (bar (40 41 42) (43 (x y z) 41))
30
+ (40 41 42)
31
+ (43 (x y z) 41)
32
+ (x y z)))
33
+
34
+ ("it finds code within interpolated strings"
35
+ (list/seek-cars 'include (parse-in-string "
36
+ <div>~~(include \"empty-name.html\")</div>
37
+ <div>~~(map λn(let name n (include \"show-name.html\")) {names})'</div>
38
+ "))
39
+ ((include "empty-name.html")
40
+ (include "show-name.html"))))
@@ -1,3 +1,17 @@
1
+ (examples-for list-single-element
2
+ ("returns nothing from an empty list"
3
+ (list-single-element nil)
4
+ nil)
5
+
6
+ ("returns first item from a list with one item"
7
+ (list-single-element '(x))
8
+ x)
9
+
10
+ ("returns nothing from a list with more than one item"
11
+ (list-single-element '(x y z))
12
+ nil))
13
+
14
+
1
15
  (examples-for iso
2
16
  ("(nil) is not the same as nil"
3
17
  (iso '(nil) nil)
@@ -37,7 +51,11 @@
37
51
  (g f (c d e) b a)))
38
52
 
39
53
  (examples-for flatten
40
- ("'flatten returns a flat list of things"
54
+ ("removes empty lists and nil"
55
+ (flatten '(a b nil (c d () e nil) f ()))
56
+ (a b c d e f))
57
+
58
+ ("returns a flat list of things"
41
59
  (flatten '((poo (x) (* x x)) (1 2 3)))
42
60
  (poo x * x x 1 2 3)))
43
61
 
@@ -187,3 +205,42 @@
187
205
  ("finds value corresponding to given key"
188
206
  (alref 'c '((a b) (c d)))
189
207
  d))
208
+
209
+ (examples-for list/fill
210
+ ("returns an overfull list unchanged"
211
+ (list/fill '(a b c) λ(just 'x) 2)
212
+ (a b c))
213
+
214
+ ("returns a full list unchanged"
215
+ (list/fill '(a b c) λ(just 'x) 3)
216
+ (a b c))
217
+
218
+ ("returns an unfull list with extra items"
219
+ (list/fill '(a b c) λ(just 'x) 4)
220
+ (a b c x))
221
+
222
+ ("returns an unfull list with extra items"
223
+ (let idx 0
224
+ (list/fill '(a b c) λ(++ idx) 10))
225
+ (a b c 1 2 3 4 5 6 7)))
226
+
227
+ (examples-for list/last
228
+ ("returns the thing if it's nil"
229
+ (list/last nil)
230
+ nil)
231
+
232
+ ("returns the thing if it's not a pair"
233
+ (list/last 42)
234
+ 42)
235
+
236
+ ("returns the cdr if it's not a pair"
237
+ (list/last '(x . y))
238
+ y)
239
+
240
+ ("returns the last item in the list"
241
+ (list/last '(x y z))
242
+ z)
243
+
244
+ ("returns nil if it's the last item in the list"
245
+ (list/last '(x y z nil))
246
+ nil))
@@ -0,0 +1,11 @@
1
+ (examples-for map-hash
2
+ ("iterates over key-value pairs"
3
+ (map-hash (fn (k v i) "pos.~i : ~k is for ~v")
4
+ { a 42 b 729 c 1024 })
5
+ ("pos.0 : a is for 42" "pos.1 : b is for 729" "pos.2 : c is for 1024"))
6
+
7
+ ("sorts keys before iterating"
8
+ (map-hash (fn (k v i) "pos.~i : ~k is for ~v")
9
+ { "aa" 1 "bbb" 2 "c" 3 }
10
+ (fn (keys) (sort-by len keys)))
11
+ ("pos.0 : c is for 3" "pos.1 : aa is for 1" "pos.2 : bbb is for 2" )))
@@ -0,0 +1,10 @@
1
+ (examples-for module
2
+ ("it overrides external namespace internally"
3
+ (with (x (fn (n) "the old outside x ~n")
4
+ y (fn (n) "the old outside y ~n"))
5
+ (module foo
6
+ (def x (n) (* 2 n))
7
+ (def y (n) (+ 2 n))
8
+ (export bar (a b) (* (x a) (y b))))
9
+ (list (foo/bar 3 5) (x 43) (y 44)))
10
+ (42 "the old outside x 43" "the old outside y 44")))
@@ -0,0 +1,6 @@
1
+ (examples-for ampersand-syntax
2
+ ("assigns multiple values at once ; value of expr is last assigned value"
3
+ (with (a 1 b { foo 2 } c { d { e 3 } })
4
+ (let res (= a 10 b.foo 20 (&d.e c) 30)
5
+ (list a b.foo c.d.e res)))
6
+ (10 20 30 30)))
@@ -9,9 +9,14 @@
9
9
  ("parses an empty symbol" (parse "||") (||) )
10
10
  ("parses a colon-syntax symbol" (parse "this:that") ((colon-syntax this that)) )
11
11
  ("parses a percent-syntax symbol" (parse "this%that") ((percent-syntax this that)) )
12
+ ("parses combined percent-colon" (parse "%this:%that") ((colon-syntax (percent-syntax || this) (percent-syntax || that))) )
12
13
  ("parses a prefix dollar" (parse "$this") ((dollar-syntax || this)))
13
14
  ("parses a prefix dollar-dot" (parse "$.this") ((dot-syntax (dollar-syntax || ||) this)))
14
15
 
16
+ ("parses combined percent-colon-dot"
17
+ (parse "%this.foo:%that.bar")
18
+ ((colon-syntax (percent-syntax || (dot-syntax this foo)) (percent-syntax || (dot-syntax that bar)))) )
19
+
15
20
  ("parse custom prefix-lists with a special-syntax prefix"
16
21
  (parse "x.y(1 2 3)")
17
22
  ((prefix-list "x.y" (1 2 3))))
@@ -24,6 +29,22 @@
24
29
  (parse "%this.and.that")
25
30
  ((percent-syntax || (dot-syntax this and that))) )
26
31
 
32
+ ("parses a plain at-symbol"
33
+ (pre-compile (car (parse "@")))
34
+ @)
35
+
36
+ ("parses a plain at-prefix-syntax symbol"
37
+ (parse "@this")
38
+ ((at-syntax || this)))
39
+
40
+ ("parses an at-prefix-mixed-with-dot-syntax symbol"
41
+ (parse "@this.and.that")
42
+ ((dot-syntax (at-syntax || this) and that)))
43
+
44
+ ("at-prefix-mixed-with-dot-syntax expands to plain hash lookup: @this.and.that equivalent to @.this.and.that"
45
+ (pre-compile (car (parse "@this.and.that")))
46
+ (hash-get (hash-get (hash-get @ (quote this)) (quote and)) (quote that)))
47
+
27
48
  ("parses a dot-syntax symbol"
28
49
  (parse "this.that.zozo")
29
50
  ((dot-syntax this that zozo)) )
@@ -49,6 +70,10 @@
49
70
  (parse-in-string (joinstr "" (list "hello, " '~ "(world), take me to your " '~ "dealer please")))
50
71
  (string-pieces "hello, " (world) ", take me to your " dealer " please"))
51
72
 
73
+ ("parses a plain string whose entire content is a single interpolation"
74
+ (parse-in-string (joinstr "" (list '~ "(hello world)")))
75
+ (hello world))
76
+
52
77
  ("parses a plain string of html text with interpolations"
53
78
  (parse-in-string "<div id='content_item_~~{id}'><label>~~{data-name-1}</label> ~~{data-text-1}</div>")
54
79
  (string-pieces "<div id='content_item_" (brace-list id) "'><label>" (brace-list data-name-1) "</label> " (brace-list data-text-1) "</div>"))
@@ -206,13 +206,12 @@ toto")
206
206
  (pp '(def yoohoo (it) (wrangle "foobar" it)))
207
207
  "(def yoohoo (it) (wrangle \"foobar\" it))")
208
208
 
209
- ("a 'let form"
210
- (pp '(let acc nil
211
- (rfnwith flattenize (x things)
212
- (if (pair? x)
213
- (eachr flattenize x)
214
- (push x acc)))
215
- acc))
209
+ ("something with a nil and t literal"
210
+ (pp '(def yoohoo (it) (wrangle nil t it)))
211
+ "(def yoohoo (it) (wrangle nil t it))")
212
+
213
+ ("a 'let form squished into one line"
214
+ (pp '(let acc nil (rfnwith flattenize (x things) (if (pair? x) (eachr flattenize x) (push x acc))) acc))
216
215
  "(let acc nil
217
216
  (rfnwith flattenize (x things)
218
217
  (if (pair? x)
@@ -221,13 +220,11 @@ toto")
221
220
  acc)")
222
221
 
223
222
 
224
- ("a real-life example from utils"
223
+ ("a real-life example from utils with improper 'if formatting"
225
224
  (pp '(def flatten (things)
226
225
  (let acc nil
227
226
  (rfnwith flattenize (x things)
228
- (if (pair? x)
229
- (eachr flattenize x)
230
- (push x acc)))
227
+ (if (pair? x) (eachr flattenize x) (push x acc)))
231
228
  acc)))
232
229
  "(def flatten (things)
233
230
  (let acc nil
@@ -282,12 +279,18 @@ toto")
282
279
 
283
280
  ("special syntax"
284
281
  (pp '(string-pieces "hello " (bang-syntax || (dot-syntax x y (ampersand-syntax foo bar))) " and welcome to " (prefix-list "%%" (a b c d)) " and friends!"))
285
- "\"hello ~~!x.y.foo&bar and welcome to ~~%%(a b c d) and friends!\"")
282
+ "\"hello ~~|!x.y.foo&bar| and welcome to ~~%%(a b c d) and friends!\"")
286
283
 
287
284
  ("percent-syntax"
288
285
  (pp '(percent-syntax || (dot-syntax x y)))
289
286
  "%x.y")
290
287
 
291
288
  ("brace list"
292
- (pp '(&x {a 1 b "two" c 'three d ,four e (sub invocation) f {sub brace list} }))
293
- "(&x { a 1 b \"two\" c 'three d ,four e (sub invocation) f { sub brace list } })"))
289
+ (pp '(let hello {a 1 b "two" c 'three d ,four e (sub invocation) f {sub brace list here} }))
290
+ "(let hello { a 1
291
+ b \"two\"
292
+ c 'three
293
+ d ,four
294
+ e (sub invocation)
295
+ f { sub brace
296
+ list here } })"))
@@ -0,0 +1,8 @@
1
+ (examples-for -
2
+ ("returns elements of first that are not in second"
3
+ (- '(a b c e) '(a b d))
4
+ (c e))
5
+
6
+ ("returns all of first if second is nil"
7
+ (- '(a b c) nil)
8
+ (a b c)))
@@ -3,14 +3,30 @@
3
3
  (⋂ '(a b c))
4
4
  (a b c))
5
5
 
6
+ ("returns a single nil arg"
7
+ (⋂ nil)
8
+ nil)
9
+
6
10
  ("returns intersection of two args"
7
11
  (⋂ '(a b c) '(a b d))
8
12
  (a b))
9
13
 
14
+ ("returns intersection of list and nil"
15
+ (⋂ '(a b c) nil)
16
+ nil)
17
+
18
+ ("returns intersection of nil and list"
19
+ (⋂ nil '(a b c))
20
+ nil)
21
+
10
22
  ("returns intersection of three args"
11
23
  (⋂ '(a b c d e) '(a b c d f) '(z b c d g))
12
24
  (b c d))
13
25
 
26
+ ("returns intersection of list, nil, and another list"
27
+ (⋂ '(a b c d e) nil '(z b c d g))
28
+ nil)
29
+
14
30
  ("returns intersection of four args"
15
31
  (⋂ '(a b c d e) '(a b c d f) '(z b d c g) '(z y g c d))
16
32
  (c d)))