1 USING: arrays assocs.extras kernel math math.order sequences tools.test ;
3 { f } [ f { } deep-at ] unit-test
4 { f } [ f { "foo" } deep-at ] unit-test
5 { f } [ H{ } { 1 2 3 } deep-at ] unit-test
6 { f } [ H{ { "a" H{ { "b" 1 } } } } { "a" "c" } deep-at ] unit-test
7 { 1 } [ H{ { "a" H{ { "b" 1 } } } } { "a" "b" } deep-at ] unit-test
8 { 4 } [ H{ { 1 H{ { 2 H{ { 3 4 } } } } } } { 1 2 3 } deep-at ] unit-test
10 { H{ { 2 1 } { 4 3 } } } [ H{ { 1 2 } { 3 4 } } assoc-invert ] unit-test
12 { H{ { "a" V{ 2 5 } } { "b" V{ 3 } } { "c" V{ 10 } } } }
14 { H{ { "a" 2 } { "b" 3 } } H{ { "a" 5 } { "c" 10 } } }
15 [ ] [ assoc-collect ] map-reduce
18 { H{ } } [ H{ { 1 2 } } 2 over delete-value-at ] unit-test
19 { H{ { 1 2 } } } [ H{ { 1 2 } } 3 over delete-value-at ] unit-test
34 } expand-values-set-at
38 H{ { 1 V{ 3 } } { 2 V{ 3 } } }
50 } expand-values-push-at
54 H{ { 1 [ sq ] } { 2 [ sq ] } }
56 { { { 1 2 { 1 } { 2 } { 1 1 } } [ sq ] } } flatten-keys
60 H{ { "1" 1 } { "2" 2 } }
62 H{ { "1" 1 } { "2" 2 } { "3" 3 } }
68 H{ { "1" 1 } { "2" 2 } { "3" 3 } }
69 [ { "1" "2" "2" } rekey-new-assoc ] keep eq?
73 H{ { "1" 1 } { "2" 2 } }
75 H{ { "1" 1 } { "2" 2 } { "3" 3 } }
81 H{ { "1" 1 } { "2" 2 } { "3" 3 } }
82 [ { "1" "2" "2" } rekey-assoc ] keep eq?
85 { H{ { 1 11 } { 2 22 } { 3 33 } } } [
86 H{ { 1 11 } { 2 20 } }
87 H{ { 2 22 } { 3 33 } }
91 { H{ { 1 11 } { 2 22 } { 3 33 } } } [
92 H{ { 2 22 } { 3 33 } }
93 H{ { 1 11 } { 2 20 } }
97 { H{ { 1 11 } { 2 20 } { 3 33 } } } [
98 H{ { 1 11 } { 2 20 } }
99 H{ { 2 22 } { 3 33 } }
103 { f } [ f f [ min ] assoc-merge ] unit-test
105 ! Ensure non-destructive
107 H{ { 1 11 } { 2 20 } }
108 H{ { 2 22 } { 3 33 } }
109 H{ { 1 11 } { 2 20 } { 3 33 } }
111 H{ { 1 11 } { 2 20 } }
112 H{ { 2 22 } { 3 33 } } 2dup
118 H{ { 1 11 } { 2 20 } { 3 33 } }
119 H{ { 2 22 } { 3 33 } }
120 H{ { 1 11 } { 2 20 } { 3 33 } }
122 H{ { 1 11 } { 2 20 } }
123 H{ { 2 22 } { 3 33 } } 2dup
128 { f } [ f [ min ] assoc-collapse ] unit-test
131 H{ { 1 11 } { 2 20 } }
132 H{ { 1 11 } { 2 20 } { 3 30 } { 4 40 } }
134 H{ { 1 11 } { 2 20 } } dup
135 H{ { 2 22 } { 3 33 } }
136 H{ { 3 30 } { 4 40 } } 3array
137 [ min ] assoc-collapse