nydp 0.4.0 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +44 -0
- data/lib/lisp/core-010-precompile.nydp +13 -16
- data/lib/lisp/core-012-utils.nydp +21 -6
- data/lib/lisp/core-015-documentation.nydp +60 -19
- data/lib/lisp/core-017-builtin-dox.nydp +50 -39
- data/lib/lisp/core-020-utils.nydp +5 -5
- data/lib/lisp/core-030-syntax.nydp +103 -61
- data/lib/lisp/core-035-flow-control.nydp +18 -9
- data/lib/lisp/core-037-list-utils.nydp +36 -14
- data/lib/lisp/core-039-module.nydp +24 -0
- data/lib/lisp/core-040-utils.nydp +41 -23
- data/lib/lisp/core-041-string-utils.nydp +37 -9
- data/lib/lisp/core-042-date-utils.nydp +21 -1
- data/lib/lisp/core-043-list-utils.nydp +93 -67
- data/lib/lisp/core-045-dox-utils.nydp +5 -0
- data/lib/lisp/core-080-pretty-print.nydp +55 -17
- data/lib/lisp/core-090-hook.nydp +35 -1
- data/lib/lisp/core-100-utils.nydp +130 -28
- data/lib/lisp/core-110-hash-utils.nydp +61 -0
- data/lib/lisp/core-120-settings.nydp +46 -0
- data/lib/lisp/core-130-validations.nydp +51 -0
- data/lib/lisp/{core-060-benchmarking.nydp → core-900-benchmarking.nydp} +108 -5
- data/lib/lisp/tests/accum-examples.nydp +28 -1
- data/lib/lisp/tests/aif-examples.nydp +8 -3
- data/lib/lisp/tests/andify-examples.nydp +7 -0
- data/lib/lisp/tests/at-syntax-examples.nydp +17 -0
- data/lib/lisp/tests/best-examples.nydp +9 -0
- data/lib/lisp/tests/builtin-tests.nydp +19 -0
- data/lib/lisp/tests/case-examples.nydp +14 -0
- data/lib/lisp/tests/cdr-set-examples.nydp +6 -0
- data/lib/lisp/tests/date-examples.nydp +56 -1
- data/lib/lisp/tests/destructuring-examples.nydp +5 -5
- data/lib/lisp/tests/detect-examples.nydp +12 -0
- data/lib/lisp/tests/dp-examples.nydp +24 -0
- data/lib/lisp/tests/empty-examples.nydp +1 -1
- data/lib/lisp/tests/error-tests.nydp +4 -4
- data/lib/lisp/tests/filter-forms-examples.nydp +30 -0
- data/lib/lisp/tests/foundation-test.nydp +12 -0
- data/lib/lisp/tests/hash-examples.nydp +26 -2
- data/lib/lisp/tests/list-grep-examples.nydp +40 -0
- data/lib/lisp/tests/list-tests.nydp +58 -1
- data/lib/lisp/tests/map-hash-examples.nydp +11 -0
- data/lib/lisp/tests/mapreduce-examples.nydp +10 -0
- data/lib/lisp/tests/module-examples.nydp +10 -0
- data/lib/lisp/tests/multi-assign-examples.nydp +6 -0
- data/lib/lisp/tests/parser-tests.nydp +21 -0
- data/lib/lisp/tests/pretty-print-tests.nydp +16 -13
- data/lib/lisp/tests/set-difference-examples.nydp +8 -0
- data/lib/lisp/tests/set-intersection-examples.nydp +32 -0
- data/lib/lisp/tests/set-union-examples.nydp +24 -0
- data/lib/lisp/tests/settings-examples.nydp +40 -0
- data/lib/lisp/tests/sort-examples.nydp +8 -0
- data/lib/lisp/tests/string-tests.nydp +61 -1
- data/lib/lisp/tests/syntax-tests.nydp +5 -1
- data/lib/lisp/tests/to-integer-examples.nydp +16 -0
- data/lib/lisp/tests/validation-examples.nydp +15 -0
- data/lib/lisp/tests/zap-examples.nydp +12 -0
- data/lib/nydp.rb +13 -7
- data/lib/nydp/assignment.rb +10 -3
- data/lib/nydp/builtin.rb +1 -1
- data/lib/nydp/builtin/abs.rb +8 -0
- data/lib/nydp/builtin/cdr_set.rb +1 -6
- data/lib/nydp/builtin/date.rb +15 -1
- data/lib/nydp/builtin/error.rb +1 -1
- data/lib/nydp/builtin/handle_error.rb +1 -1
- data/lib/nydp/builtin/hash.rb +27 -45
- data/lib/nydp/builtin/inspect.rb +1 -1
- data/lib/nydp/builtin/plus.rb +10 -2
- data/lib/nydp/builtin/rand.rb +18 -0
- data/lib/nydp/builtin/random_string.rb +2 -2
- data/lib/nydp/builtin/ruby_wrap.rb +72 -0
- data/lib/nydp/builtin/set_intersection.rb +8 -0
- data/lib/nydp/builtin/set_union.rb +8 -0
- data/lib/nydp/builtin/string_match.rb +2 -2
- data/lib/nydp/builtin/string_pad_left.rb +7 -0
- data/lib/nydp/builtin/string_pad_right.rb +7 -0
- data/lib/nydp/builtin/string_replace.rb +1 -1
- data/lib/nydp/builtin/string_split.rb +1 -2
- data/lib/nydp/builtin/to_integer.rb +23 -0
- data/lib/nydp/builtin/to_string.rb +2 -9
- data/lib/nydp/builtin/type_of.rb +9 -6
- data/lib/nydp/closure.rb +0 -3
- data/lib/nydp/cond.rb +23 -1
- data/lib/nydp/context_symbol.rb +14 -6
- data/lib/nydp/core.rb +45 -33
- data/lib/nydp/core_ext.rb +54 -0
- data/lib/nydp/date.rb +37 -31
- data/lib/nydp/function_invocation.rb +34 -26
- data/lib/nydp/hash.rb +5 -6
- data/lib/nydp/helper.rb +41 -25
- data/lib/nydp/interpreted_function.rb +68 -40
- data/lib/nydp/literal.rb +1 -1
- data/lib/nydp/pair.rb +25 -9
- data/lib/nydp/parser.rb +8 -6
- data/lib/nydp/string_atom.rb +16 -22
- data/lib/nydp/symbol.rb +40 -27
- data/lib/nydp/symbol_lookup.rb +7 -7
- data/lib/nydp/tokeniser.rb +2 -2
- data/lib/nydp/truth.rb +17 -10
- data/lib/nydp/version.rb +1 -1
- data/lib/nydp/vm.rb +7 -2
- data/nydp.gemspec +2 -4
- data/spec/date_spec.rb +115 -22
- data/spec/embedded_spec.rb +12 -12
- data/spec/foreign_hash_spec.rb +14 -2
- data/spec/hash_non_hash_behaviour_spec.rb +7 -7
- data/spec/hash_spec.rb +24 -2
- data/spec/nydp_spec.rb +14 -2
- data/spec/parser_spec.rb +27 -16
- data/spec/rand_spec.rb +45 -0
- data/spec/spec_helper.rb +13 -1
- data/spec/symbol_spec.rb +31 -0
- data/spec/time_spec.rb +1 -1
- metadata +38 -37
- data/lib/nydp/builtin/car.rb +0 -7
- data/lib/nydp/builtin/cdr.rb +0 -7
- data/lib/nydp/builtin/cons.rb +0 -9
@@ -20,10 +20,10 @@
|
|
20
20
|
(on-err (error "bar")
|
21
21
|
(on-err (error "toto")
|
22
22
|
(error "primum errorum")))))
|
23
|
-
"
|
24
|
-
|
25
|
-
|
26
|
-
|
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)
|
@@ -44,3 +44,33 @@
|
|
44
44
|
(this)
|
45
45
|
(that))))
|
46
46
|
((("hello") ("more details") ("very rigourous")) ((this) (that)))))
|
47
|
+
|
48
|
+
(examples-for filter-comments
|
49
|
+
("returns nil for nil"
|
50
|
+
(filter-comments nil nil)
|
51
|
+
nil)
|
52
|
+
|
53
|
+
("returns atom for atom"
|
54
|
+
(filter-comments 12 nil)
|
55
|
+
12)
|
56
|
+
|
57
|
+
("returns list for list"
|
58
|
+
(filter-comments '(a b c d) nil)
|
59
|
+
(a b c d))
|
60
|
+
|
61
|
+
("returns list without comment for list with comment"
|
62
|
+
(filter-comments '(a b (comment "hahaha") c d) nil)
|
63
|
+
(a b c d))
|
64
|
+
|
65
|
+
("returns nothing for comment"
|
66
|
+
(filter-comments '((comment "hahaha")) nil)
|
67
|
+
nil)
|
68
|
+
|
69
|
+
("weeds out nested comments"
|
70
|
+
(filter-comments '(1 2 (3 4
|
71
|
+
(comment "yoyo") 5
|
72
|
+
(6 7 (comment "eight") 8 9)
|
73
|
+
{ 10 (comment "eleven") 11 12 13 }
|
74
|
+
(comment "fourteen") 14) (comment "fifteen") 15
|
75
|
+
(if 16 (comment "seventeen") 17 (comment "eighteen") 18 19)))
|
76
|
+
(1 2 (3 4 5 (6 7 8 9) (brace-list 10 11 12 13) 14) 15 (if 16 17 18 19))))
|
@@ -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
|
-
(
|
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
|
-
("
|
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 mapreduce
|
2
|
+
("maps a function over a list and sums the result"
|
3
|
+
(mapreduce car + '((2 3) (5 7) (11 13)) 0)
|
4
|
+
18)
|
5
|
+
|
6
|
+
("extracts an attribute and sums the result"
|
7
|
+
(mapreduce &age + (list { name "a" age 10 }
|
8
|
+
{ name "b" age 7 }
|
9
|
+
{ name "c" age 12 }) 0)
|
10
|
+
29))
|
@@ -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")))
|
@@ -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)) )
|
@@ -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
|
210
|
-
(pp '(
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
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
|
@@ -289,5 +286,11 @@ toto")
|
|
289
286
|
"%x.y")
|
290
287
|
|
291
288
|
("brace list"
|
292
|
-
(pp '(
|
293
|
-
|
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,32 @@
|
|
1
|
+
(examples-for ⋂
|
2
|
+
("returns a single arg"
|
3
|
+
(⋂ '(a b c))
|
4
|
+
(a b c))
|
5
|
+
|
6
|
+
("returns a single nil arg"
|
7
|
+
(⋂ nil)
|
8
|
+
nil)
|
9
|
+
|
10
|
+
("returns intersection of two args"
|
11
|
+
(⋂ '(a b c) '(a b d))
|
12
|
+
(a b))
|
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
|
+
|
22
|
+
("returns intersection of three args"
|
23
|
+
(⋂ '(a b c d e) '(a b c d f) '(z b c d g))
|
24
|
+
(b c d))
|
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
|
+
|
30
|
+
("returns intersection of four args"
|
31
|
+
(⋂ '(a b c d e) '(a b c d f) '(z b d c g) '(z y g c d))
|
32
|
+
(c d)))
|
@@ -0,0 +1,24 @@
|
|
1
|
+
(examples-for ⋃
|
2
|
+
("returns a single arg"
|
3
|
+
(⋃ '(a b c))
|
4
|
+
(a b c))
|
5
|
+
|
6
|
+
("returns union of two args"
|
7
|
+
(⋃ '(a b c) '(a b d))
|
8
|
+
(a b c d))
|
9
|
+
|
10
|
+
("returns union of arg and nil"
|
11
|
+
(⋃ '(a b c) nil)
|
12
|
+
(a b c))
|
13
|
+
|
14
|
+
("returns union of three args"
|
15
|
+
(⋃ '(a b c d e) '(a b c d f) '(z b c d g))
|
16
|
+
(a b c d e f z g))
|
17
|
+
|
18
|
+
("returns union of arg nil arg"
|
19
|
+
(⋃ '(a b c d e) nil '(z b c d g))
|
20
|
+
(a b c d e z g))
|
21
|
+
|
22
|
+
("returns union of four args"
|
23
|
+
(⋃ '(a b c d e) '(a b c d f) '(z b d c g) '(z y g c d))
|
24
|
+
(a b c d e f z g y)))
|
@@ -0,0 +1,40 @@
|
|
1
|
+
(def-setting "testing.reset.string" "hello world")
|
2
|
+
(def-setting "testing.reset.fn" to-string)
|
3
|
+
|
4
|
+
(examples-for settings/fn
|
5
|
+
("returns arg if it is a sym"
|
6
|
+
(settings/fn 'foobar)
|
7
|
+
foobar)
|
8
|
+
|
9
|
+
("returns fn wrapper for arg if it is a string"
|
10
|
+
(settings/fn "hello")
|
11
|
+
(k "hello"))
|
12
|
+
|
13
|
+
("returns fn wrapper for arg if it is a number"
|
14
|
+
(settings/fn 42)
|
15
|
+
(k 42))
|
16
|
+
|
17
|
+
("returns fn wrapper for arg if it is nil"
|
18
|
+
(settings/fn nil)
|
19
|
+
(k nil))
|
20
|
+
|
21
|
+
("wraps arg in a fn expression if it is a hash"
|
22
|
+
(settings/fn '{ a 1 b 2 })
|
23
|
+
(k { a 1 b 2 }))
|
24
|
+
|
25
|
+
("wraps arg in a fn expression if it is a complex expression"
|
26
|
+
(settings/fn '(let foo this that (rfnwith (complex stuff) (%td.tricky#syntax))))
|
27
|
+
(fn (_) (let foo this that (rfnwith (complex stuff) ((percent-syntax || (dot-syntax td tricky#syntax))))))))
|
28
|
+
|
29
|
+
(examples-for reset-setting
|
30
|
+
("restores a setting to its original value"
|
31
|
+
(do (set-setting "testing.reset.string" "goodbye, dear life")
|
32
|
+
(reset-setting "testing.reset.string")
|
33
|
+
(setting "testing.reset.string"))
|
34
|
+
"hello world")
|
35
|
+
|
36
|
+
("restores a setting to its original function value"
|
37
|
+
(do (set-setting "testing.reset.fn" "goodbye, dear life")
|
38
|
+
(reset-setting "testing.reset.fn")
|
39
|
+
(setting "testing.reset.fn"))
|
40
|
+
"testing.reset.fn"))
|