functionalscript 0.0.289 → 0.0.293

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,8 +9,6 @@ FunctionalScript is a pure functional programming language and a strict subset o
9
9
 
10
10
  Create a new FunctionalScript repository on GitHub [here](https://github.com/functionalscript/template/generate).
11
11
 
12
- Try FunctionalScript [here](https://functionalscript.com/).
13
-
14
12
  ## 1. Design Principles
15
13
 
16
14
  In FunctionalScript:
@@ -186,3 +184,56 @@ const f = x => {
186
184
  return r
187
185
  }
188
186
  ```
187
+
188
+ ## 5. Statements
189
+
190
+ `{ A_LIST_OF_STATEMENTS }` is one or many statements seperated by the newline control character. One of these statements mentioned earlier was [definition](#25-Definitions), also known as a [const](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const) statement. The other statements are described below.
191
+
192
+ ### 5.1 Let
193
+
194
+ [Let](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let) declares a local mutable alias for immutable objects. For example
195
+
196
+ ```js
197
+ let x = [5]
198
+ // you can assign another immutable object to the alias at any time.
199
+ x = [3, 4]
200
+ //but you can't change the properties of the immutable object.
201
+ x[0] = 3 // < invalid
202
+ //let aliases can not be referenced from another arrow function.
203
+ const f = () => x // < invalid
204
+ ```
205
+
206
+
207
+
208
+ This mutable object cannot be used in [closures](https://en.wikipedia.org/wiki/Closure_(computer_programming)) or nested functions.
209
+
210
+ An example of incorrect code would look like this:
211
+
212
+ ```js
213
+ let x = 5
214
+ const f = () => x
215
+ ```
216
+
217
+ ### 5.2 Return
218
+
219
+ [Return](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return)
220
+
221
+ ### 5.3 If...Else
222
+
223
+ [If...Else](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else)
224
+
225
+ ### 5.4 Switch
226
+
227
+ [Switch](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch)
228
+
229
+ ### 5.5 Throw
230
+
231
+ [Throw](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/throw). FunctionalScript allows to throw exceptions but it doesn't catch them. You should only be using Statement throw in non-recoverable situations. It could be compared to [panic in Rust](https://doc.rust-lang.org/std/macro.panic.html).
232
+
233
+ ### 5.6 While
234
+
235
+ [While](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while)
236
+
237
+ ### 5.7 Block
238
+
239
+ [Block](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/block)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.0.289",
3
+ "version": "0.0.293",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "homepage": "https://github.com/functionalscript/functionalscript#readme",
30
30
  "devDependencies": {
31
- "@types/node": "^16.11.12",
32
- "typescript": "^4.5.3"
31
+ "@types/node": "^16.11.19",
32
+ "typescript": "^4.5.4"
33
33
  }
34
34
  }
@@ -79,14 +79,16 @@ Posible actions:
79
79
 
80
80
  ## Concat
81
81
 
82
- `concat` returns either `Branch1` or `Branch3`
83
-
84
- |`a` |`b` | |size |
85
- |------------------|-------------------|-------------------------------------------------|-----|
86
- |`[av]` |`[bv]` |`[[av,bv]]` | |
87
- | |`[bv0,bv1]` |`[a,bv0,[bv1]]` | |
88
- |`[av0,av1]` | |`[[av0],av1,b]` | |
89
- |`[...aHead,aLast]`|`[bFirst,...bLast]`|`up([...aHead,...concat(aLast,bFirst),...bTail])`|5..11|
82
+ `concat` accepts `left` and `right` branches of the same level.
83
+
84
+ |left |right |result |
85
+ |-------------|-------------|--------------------------|
86
+ |[an0] |[bn0] |[an0, value, r?] |
87
+ |[an0] |[bn0,bv1,bn2]|[an0, value, r?, bv1, bn2]|
88
+ |[an0,av1,an2]|[bn0] |[an0, av1, an2, value, r?]|
89
+
90
+ `popLeft` accepts `node` and returns
91
+ `value` and `['leaf', [] | Leaf1]` | `['branch', Branch1 | Branch3 | Branch5]`
90
92
 
91
93
  ## Up
92
94
 
@@ -0,0 +1,165 @@
1
+ const _ = require('..')
2
+ const { todo } = require('../../../dev')
3
+ const cmp = require('../../function/compare')
4
+ const find = require('../find')
5
+ const list = require('../../list')
6
+ const array = require('../../array')
7
+
8
+ /**
9
+ * @template T
10
+ * @typedef {undefined | _.Leaf1<T>} Leaf01
11
+ */
12
+
13
+ /**
14
+ * @template T
15
+ * @typedef {{
16
+ * readonly first: Leaf01<T>,
17
+ * readonly tail: find.Path<T>
18
+ * }} RemovePath
19
+ */
20
+
21
+ /** @type {<T>(tail: find.Path<T>) => (n: _.Node<T>) => readonly[T, RemovePath<T>]} */
22
+ const path = tail => n => {
23
+ switch (n.length) {
24
+ case 1: { return [n[0], { first: undefined, tail }] }
25
+ case 2: { return [n[0], { first: [n[1]], tail }] }
26
+ case 3: { return path({ first: [0, n], tail })(n[0]) }
27
+ case 5: { return path({ first: [0, n], tail })(n[0]) }
28
+ }
29
+ }
30
+
31
+ /**
32
+ * @template T
33
+ * @typedef {_.Branch1<T> | _.Branch3<T> | _.Branch5<T>} Branch
34
+ */
35
+
36
+ /** @type {<T>(a: Branch<T>) => (n: _.Branch3<T>) => _.Branch1<T> | _.Branch3<T>} */
37
+ const reduceValue0 = a => n => {
38
+ const [, v1, n2] = n
39
+ if (a.length === 1) {
40
+ switch (n2.length) {
41
+ case 3: { return [[a[0], v1, ...n2]] }
42
+ case 5: { return [[a[0], v1, n2[0]], n2[1], [n2[2], n2[3], n2[4]]] }
43
+ default: { throw 'invalid node' }
44
+ }
45
+ } else {
46
+ return [a, v1, n2]
47
+ }
48
+ }
49
+
50
+ /** @type {<T>(a: Branch<T>) => (n: _.Branch3<T>) => _.Branch1<T> | _.Branch3<T>} */
51
+ const reduceValue2 = a => n => {
52
+ const [n0, v1, ] = n
53
+ if (a.length === 1) {
54
+ switch (n0.length) {
55
+ case 3: { return [[...n0, v1, a[0]]] }
56
+ case 5: { return [[n0[0], n0[1], n0[2]], n0[3], [n0[4], v1, a[0]]] }
57
+ default: { throw 'invalid node' }
58
+ }
59
+ } else {
60
+ return [n0, v1, a]
61
+ }
62
+ }
63
+
64
+ /** @type {<T>(a: Leaf01<T>) => (n: _.Branch3<T>) => _.Branch1<T> | _.Branch3<T>} */
65
+ const initValue0 = a => n => {
66
+ const [, v1, n2] = n
67
+ if (a === undefined) {
68
+ switch (n2.length) {
69
+ case 1: { return [[v1, ...n2]] }
70
+ case 2: { return [[v1], n2[0], [n2[1]]] }
71
+ default: { throw 'invalid node' }
72
+ }
73
+ } else {
74
+ return [a, v1, n2]
75
+ }
76
+ }
77
+
78
+ /** @type {<T>(a: Leaf01<T>) => (n: _.Branch3<T>) => _.Branch1<T> | _.Branch3<T>} */
79
+ const initValue1 = a => n => {
80
+ const [n0, v1] = n
81
+ if (a === undefined) {
82
+ switch (n0.length) {
83
+ case 1: { return [[...n0, v1]] }
84
+ case 2: { return [[n0[0]], n0[1], [v1]] }
85
+ default: { throw 'invalid node' }
86
+ }
87
+ } else { return [n0, v1, a] }
88
+ }
89
+
90
+ /**
91
+ * @template A,T
92
+ * @typedef {(a: A) => (n: _.Branch3<T>) => _.Branch1<T> | _.Branch3<T>} Merge
93
+ */
94
+
95
+ /** @type {<A, T>(ms: array.Array2<Merge<A, T>>) => (a: A) => (i: find.PathItem<T>) => Branch<T>} */
96
+ const reduceX = ms => a => i => {
97
+ const [m0, m2] = ms
98
+ /** @typedef {typeof ms extends array.Array2<Merge<infer A, infer T>> ? [A,T] : never} AT */
99
+ /** @typedef {AT[0]} A */
100
+ /** @typedef {AT[1]} T */
101
+ /** @type {(m: Merge<A, T>) => Branch<T>} */
102
+ const f = m => {
103
+ const n = i[1]
104
+ const ra = m(a)
105
+ return n.length === 3 ? ra(n) : [...ra([n[0], n[1], n[2]]), n[3], n[4]]
106
+ }
107
+ switch (i[0]) {
108
+ case 0: { return f(m0) }
109
+ case 2: { return f(m2) }
110
+ case 4: {
111
+ const n = i[1]
112
+ return [n[0], n[1], ...m2(a)([n[2], n[3], n[4]])]
113
+ }
114
+ }
115
+ }
116
+
117
+ const reduce = list.reduce(reduceX([reduceValue0, reduceValue2]))
118
+
119
+ const initReduce = reduceX([initValue0, initValue1])
120
+
121
+ /** @type {<T>(c: cmp.Compare<T>) => (node: _.Node<T>) => undefined | _.Node<T>} */
122
+ const remove = c => node => {
123
+ /** @typedef {typeof c extends cmp.Compare<infer T> ? T : never} T */
124
+ /** @type {() => undefined | RemovePath<T>} */
125
+ const f = () => {
126
+ const { first, tail } = find.find(c)(node)
127
+ /** @type {(n: _.Node<T>) => (f: (v: T) => find.PathItem<T>) => RemovePath<T>} */
128
+ const branch = n => f => {
129
+ const [v, p] = path(/** @type {find.Path<T>} */(undefined))(n)
130
+ return { first: p.first, tail: list.concat(p.tail)({ first: f(v), tail }) }
131
+ }
132
+ switch (first[0]) {
133
+ case 1: {
134
+ const n = first[1]
135
+ switch (n.length) {
136
+ case 1: { return { first: undefined, tail } }
137
+ case 2: { return { first: [n[1]], tail } }
138
+ case 3: { return branch(n[2])(v => [2, [n[0], v, n[2]]]) }
139
+ case 5: { return branch(n[2])(v => [2, [n[0], v, n[2], n[3], n[4]]]) }
140
+ }
141
+ }
142
+ case 3: {
143
+ const n = first[1]
144
+ switch (n.length) {
145
+ case 2: { return { first: [n[0]], tail } }
146
+ case 5: { return branch(n[4])(v => [4, [n[0], n[1], n[2], v, n[4]]]) }
147
+ }
148
+ }
149
+ default: { return undefined }
150
+ }
151
+ }
152
+ const r = f()
153
+ if (r === undefined) { return node }
154
+ const { first, tail } = r
155
+ const tailR = list.next(tail)
156
+ if (tailR === undefined) { return first }
157
+ const { first: tf, tail: tt } = tailR
158
+ const result = reduce(initReduce(first)(tf))(tt)
159
+ return result.length === 1 ? result[0] : result
160
+ }
161
+
162
+ module.exports = {
163
+ /** @readonly */
164
+ remove,
165
+ }
@@ -0,0 +1,409 @@
1
+ const _ = require('.')
2
+ const btree = require('..')
3
+ const s = require('../set')
4
+ const { stringCmp } = require('../../function/compare')
5
+ const json = require('../../../json')
6
+ const { sort } = require('../../object')
7
+
8
+ /** @type {(node: btree.Node<string>) => (value: string) => btree.Node<string>} */
9
+ const set = node => value => s.set(stringCmp(value))(value)(node)
10
+
11
+ /** @type {(node: btree.Node<string>) => (value: string) => btree.Node<string> | undefined} */
12
+ const remove = node => value => _.remove(stringCmp(value))(node)
13
+
14
+ const jsonStr = json.stringify(sort)
15
+
16
+ {
17
+ /** @type {btree.Node<string> | undefined} */
18
+ let _map = ['1']
19
+ for (let i = 2; i <= 38; i++)
20
+ _map = set(_map)((i * i).toString())
21
+ {
22
+ const r = jsonStr(_map)
23
+ if (r !==
24
+ '[[[[["1"],"100",["1024"]],"1089",[["1156"],"121",["1225"]]],' +
25
+ '"1296",' +
26
+ '[[["1369"],"144",["1444"]],"16",[["169"],"196",["225"]]]],' +
27
+ '"25",' +
28
+ '[[[["256"],"289",["324"],"36",["361"]],"4",[["400"],"441",["484"]]],' +
29
+ '"49",' +
30
+ '[[["529"],"576",["625"]],"64",[["676"],"729",["784"]],"81",[["841"],"9",["900","961"]]]]]'
31
+ ) { throw r }
32
+ }
33
+ {
34
+ _map = remove(_map)("0")
35
+ if (_map === undefined) { throw 'undefined' }
36
+ const r = jsonStr(_map)
37
+ if (r !==
38
+ '[[[[["1"],"100",["1024"]],"1089",[["1156"],"121",["1225"]]],' +
39
+ '"1296",' +
40
+ '[[["1369"],"144",["1444"]],"16",[["169"],"196",["225"]]]],' +
41
+ '"25",' +
42
+ '[[[["256"],"289",["324"],"36",["361"]],"4",[["400"],"441",["484"]]],' +
43
+ '"49",' +
44
+ '[[["529"],"576",["625"]],"64",[["676"],"729",["784"]],"81",[["841"],"9",["900","961"]]]]]'
45
+ ) { throw r }
46
+ }
47
+ {
48
+ _map = remove(_map)("1")
49
+ if (_map === undefined) { throw 'undefined' }
50
+ const r = jsonStr(_map)
51
+ if (r !==
52
+ '[[[["100","1024"],"1089",["1156"],"121",["1225"]],"1296",[["1369"],"144",["1444"]],"16",[["169"],"196",["225"]]],' +
53
+ '"25",' +
54
+ '[[["256"],"289",["324"],"36",["361"]],"4",[["400"],"441",["484"]]],' +
55
+ '"49",' +
56
+ '[[["529"],"576",["625"]],"64",[["676"],"729",["784"]],"81",[["841"],"9",["900","961"]]]]'
57
+ ) { throw r }
58
+ }
59
+ {
60
+ _map = remove(_map)("4")
61
+ if (_map === undefined) { throw 'undefined' }
62
+ const r = jsonStr(_map)
63
+ if (r !==
64
+ '[[[["100","1024"],"1089",["1156"],"121",["1225"]],"1296",[["1369"],"144",["1444"]],"16",[["169"],"196",["225"]]],' +
65
+ '"25",' +
66
+ '[[["256"],"289",["324"]],"36",[["361"],"400",["441","484"]]],' +
67
+ '"49",' +
68
+ '[[["529"],"576",["625"]],"64",[["676"],"729",["784"]],"81",[["841"],"9",["900","961"]]]]'
69
+ ) { throw r }
70
+ }
71
+ {
72
+ _map = remove(_map)("9")
73
+ if (_map === undefined) { throw 'undefined' }
74
+ const r = jsonStr(_map)
75
+ if (r !==
76
+ '[[[["100","1024"],"1089",["1156"],"121",["1225"]],"1296",[["1369"],"144",["1444"]],"16",[["169"],"196",["225"]]],' +
77
+ '"25",' +
78
+ '[[["256"],"289",["324"]],"36",[["361"],"400",["441","484"]]],' +
79
+ '"49",' +
80
+ '[[["529"],"576",["625"]],"64",[["676"],"729",["784"]],"81",[["841"],"900",["961"]]]]'
81
+ ) { throw r }
82
+ }
83
+ {
84
+ _map = remove(_map)("16")
85
+ if (_map === undefined) { throw 'undefined' }
86
+ const r = jsonStr(_map)
87
+ if (r !==
88
+ '[[[["100","1024"],"1089",["1156"],"121",["1225"]],"1296",[["1369"],"144",["1444"],"169",["196","225"]]],' +
89
+ '"25",' +
90
+ '[[["256"],"289",["324"]],"36",[["361"],"400",["441","484"]]],' +
91
+ '"49",' +
92
+ '[[["529"],"576",["625"]],"64",[["676"],"729",["784"]],"81",[["841"],"900",["961"]]]]'
93
+ ) { throw r }
94
+ }
95
+ {
96
+ _map = remove(_map)("25")
97
+ if (_map === undefined) { throw 'undefined' }
98
+ const r = jsonStr(_map)
99
+ if (r !==
100
+ '[[[["100","1024"],"1089",["1156"],"121",["1225"]],"1296",[["1369"],"144",["1444"],"169",["196","225"]],"256",[["289","324"],"36",["361"],"400",["441","484"]]],' +
101
+ '"49",' +
102
+ '[[["529"],"576",["625"]],"64",[["676"],"729",["784"]],"81",[["841"],"900",["961"]]]]'
103
+ ) { throw r }
104
+ }
105
+ {
106
+ _map = remove(_map)("36")
107
+ if (_map === undefined) { throw 'undefined' }
108
+ const r = jsonStr(_map)
109
+ if (r !==
110
+ '[[[["100","1024"],"1089",["1156"],"121",["1225"]],"1296",[["1369"],"144",["1444"],"169",["196","225"]],"256",[["289"],"324",["361"],"400",["441","484"]]],' +
111
+ '"49",' +
112
+ '[[["529"],"576",["625"]],"64",[["676"],"729",["784"]],"81",[["841"],"900",["961"]]]]'
113
+ ) { throw r }
114
+ }
115
+ {
116
+ _map = remove(_map)("49")
117
+ if (_map === undefined) { throw 'undefined' }
118
+ const r = jsonStr(_map)
119
+ if (r !==
120
+ '[[[["100","1024"],"1089",["1156"],"121",["1225"]],"1296",[["1369"],"144",["1444"],"169",["196","225"]],"256",[["289"],"324",["361"],"400",["441","484"]]],' +
121
+ '"529",' +
122
+ '[[["576","625"],"64",["676"],"729",["784"]],"81",[["841"],"900",["961"]]]]'
123
+ ) { throw r }
124
+ }
125
+ {
126
+ _map = remove(_map)("64")
127
+ if (_map === undefined) { throw 'undefined' }
128
+ const r = jsonStr(_map)
129
+ if (r !==
130
+ '[[[["100","1024"],"1089",["1156"],"121",["1225"]],"1296",[["1369"],"144",["1444"],"169",["196","225"]],"256",[["289"],"324",["361"],"400",["441","484"]]],' +
131
+ '"529",' +
132
+ '[[["576"],"625",["676"],"729",["784"]],"81",[["841"],"900",["961"]]]]'
133
+ ) { throw r }
134
+ }
135
+ {
136
+ _map = remove(_map)("81")
137
+ if (_map === undefined) { throw 'undefined' }
138
+ const r = jsonStr(_map)
139
+ if (r !==
140
+ '[[[["100","1024"],"1089",["1156"],"121",["1225"]],"1296",[["1369"],"144",["1444"],"169",["196","225"]],"256",[["289"],"324",["361"],"400",["441","484"]]],' +
141
+ '"529",' +
142
+ '[[["576"],"625",["676"]],"729",[["784"],"841",["900","961"]]]]'
143
+ ) { throw r }
144
+ }
145
+ {
146
+ _map = remove(_map)("100")
147
+ if (_map === undefined) { throw 'undefined' }
148
+ const r = jsonStr(_map)
149
+ if (r !==
150
+ '[[[["1024"],"1089",["1156"],"121",["1225"]],"1296",[["1369"],"144",["1444"],"169",["196","225"]],"256",[["289"],"324",["361"],"400",["441","484"]]],' +
151
+ '"529",' +
152
+ '[[["576"],"625",["676"]],"729",[["784"],"841",["900","961"]]]]'
153
+ ) { throw r }
154
+ }
155
+ {
156
+ _map = remove(_map)("121")
157
+ if (_map === undefined) { throw 'undefined' }
158
+ const r = jsonStr(_map)
159
+ if (r !==
160
+ '[[[["1024"],"1089",["1156","1225"]],"1296",[["1369"],"144",["1444"],"169",["196","225"]],"256",[["289"],"324",["361"],"400",["441","484"]]],' +
161
+ '"529",' +
162
+ '[[["576"],"625",["676"]],"729",[["784"],"841",["900","961"]]]]'
163
+ ) { throw r }
164
+ }
165
+ {
166
+ _map = remove(_map)("144")
167
+ if (_map === undefined) { throw 'undefined' }
168
+ const r = jsonStr(_map)
169
+ if (r !==
170
+ '[[[["1024"],"1089",["1156","1225"]],"1296",[["1369","1444"],"169",["196","225"]],"256",[["289"],"324",["361"],"400",["441","484"]]],' +
171
+ '"529",' +
172
+ '[[["576"],"625",["676"]],"729",[["784"],"841",["900","961"]]]]'
173
+ ) { throw r }
174
+ }
175
+ {
176
+ _map = remove(_map)("169")
177
+ if (_map === undefined) { throw 'undefined' }
178
+ const r = jsonStr(_map)
179
+ if (r !==
180
+ '[[[["1024"],"1089",["1156","1225"]],"1296",[["1369","1444"],"196",["225"]],"256",[["289"],"324",["361"],"400",["441","484"]]],' +
181
+ '"529",' +
182
+ '[[["576"],"625",["676"]],"729",[["784"],"841",["900","961"]]]]'
183
+ ) { throw r }
184
+ }
185
+ {
186
+ _map = remove(_map)("196")
187
+ if (_map === undefined) { throw 'undefined' }
188
+ const r = jsonStr(_map)
189
+ if (r !==
190
+ '[[[["1024"],"1089",["1156","1225"]],"1296",[["1369"],"1444",["225"]],"256",[["289"],"324",["361"],"400",["441","484"]]],' +
191
+ '"529",' +
192
+ '[[["576"],"625",["676"]],"729",[["784"],"841",["900","961"]]]]'
193
+ ) { throw r }
194
+ }
195
+ {
196
+ _map = remove(_map)("225")
197
+ if (_map === undefined) { throw 'undefined' }
198
+ const r = jsonStr(_map)
199
+ if (r !==
200
+ '[[[["1024"],"1089",["1156","1225"],"1296",["1369","1444"]],"256",[["289"],"324",["361"],"400",["441","484"]]],' +
201
+ '"529",' +
202
+ '[[["576"],"625",["676"]],"729",[["784"],"841",["900","961"]]]]'
203
+ ) { throw r }
204
+ }
205
+ {
206
+ _map = remove(_map)("256")
207
+ if (_map === undefined) { throw 'undefined' }
208
+ const r = jsonStr(_map)
209
+ if (r !==
210
+ '[[[["1024"],"1089",["1156","1225"],"1296",["1369","1444"]],"289",[["324","361"],"400",["441","484"]]],' +
211
+ '"529",' +
212
+ '[[["576"],"625",["676"]],"729",[["784"],"841",["900","961"]]]]'
213
+ ) { throw r }
214
+ }
215
+ {
216
+ _map = remove(_map)("289")
217
+ if (_map === undefined) { throw 'undefined' }
218
+ const r = jsonStr(_map)
219
+ if (r !==
220
+ '[[[["1024"],"1089",["1156","1225"],"1296",["1369","1444"]],"324",[["361"],"400",["441","484"]]],' +
221
+ '"529",' +
222
+ '[[["576"],"625",["676"]],"729",[["784"],"841",["900","961"]]]]'
223
+ ) { throw r }
224
+ }
225
+ {
226
+ _map = remove(_map)("324")
227
+ if (_map === undefined) { throw 'undefined' }
228
+ const r = jsonStr(_map)
229
+ if (r !==
230
+ '[[[["1024"],"1089",["1156","1225"],"1296",["1369","1444"]],"361",[["400"],"441",["484"]]],' +
231
+ '"529",' +
232
+ '[[["576"],"625",["676"]],"729",[["784"],"841",["900","961"]]]]'
233
+ ) { throw r }
234
+ }
235
+ {
236
+ _map = remove(_map)("361")
237
+ if (_map === undefined) { throw 'undefined' }
238
+ const r = jsonStr(_map)
239
+ if (r !==
240
+ '[[[["1024"],"1089",["1156","1225"]],"1296",[["1369","1444"],"400",["441","484"]]],' +
241
+ '"529",' +
242
+ '[[["576"],"625",["676"]],"729",[["784"],"841",["900","961"]]]]'
243
+ ) { throw r }
244
+ }
245
+ {
246
+ _map = remove(_map)("400")
247
+ if (_map === undefined) { throw 'undefined' }
248
+ const r = jsonStr(_map)
249
+ if (r !==
250
+ '[[[["1024"],"1089",["1156","1225"]],"1296",[["1369","1444"],"441",["484"]]],' +
251
+ '"529",' +
252
+ '[[["576"],"625",["676"]],"729",[["784"],"841",["900","961"]]]]'
253
+ ) { throw r }
254
+ }
255
+ {
256
+ _map = remove(_map)("441")
257
+ if (_map === undefined) { throw 'undefined' }
258
+ const r = jsonStr(_map)
259
+ if (r !==
260
+ '[[[["1024"],"1089",["1156","1225"]],"1296",[["1369"],"1444",["484"]]],' +
261
+ '"529",' +
262
+ '[[["576"],"625",["676"]],"729",[["784"],"841",["900","961"]]]]'
263
+ ) { throw r }
264
+ }
265
+ {
266
+ _map = remove(_map)("484")
267
+ if (_map === undefined) { throw 'undefined' }
268
+ const r = jsonStr(_map)
269
+ if (r !==
270
+ '[[["1024"],"1089",["1156","1225"],"1296",["1369","1444"]],' +
271
+ '"529",' +
272
+ '[["576"],"625",["676"]],' +
273
+ '"729",' +
274
+ '[["784"],"841",["900","961"]]]'
275
+ ) { throw r }
276
+ }
277
+ {
278
+ _map = remove(_map)("529")
279
+ if (_map === undefined) { throw 'undefined' }
280
+ const r = jsonStr(_map)
281
+ if (r !==
282
+ '[[["1024"],"1089",["1156","1225"]],"1296",[["1369","1444"],"576",["625","676"]],' +
283
+ '"729",' +
284
+ '[["784"],"841",["900","961"]]]'
285
+ ) { throw r }
286
+ }
287
+ {
288
+ _map = remove(_map)("576")
289
+ if (_map === undefined) { throw 'undefined' }
290
+ const r = jsonStr(_map)
291
+ if (r !==
292
+ '[[["1024"],"1089",["1156","1225"]],"1296",[["1369","1444"],"625",["676"]],' +
293
+ '"729",' +
294
+ '[["784"],"841",["900","961"]]]'
295
+ ) { throw r }
296
+ }
297
+ {
298
+ _map = remove(_map)("625")
299
+ if (_map === undefined) { throw 'undefined' }
300
+ const r = jsonStr(_map)
301
+ if (r !==
302
+ '[[["1024"],"1089",["1156","1225"]],"1296",[["1369"],"1444",["676"]],' +
303
+ '"729",' +
304
+ '[["784"],"841",["900","961"]]]'
305
+ ) { throw r }
306
+ }
307
+ {
308
+ _map = remove(_map)("676")
309
+ if (_map === undefined) { throw 'undefined' }
310
+ const r = jsonStr(_map)
311
+ if (r !==
312
+ '[[["1024"],"1089",["1156","1225"],"1296",["1369","1444"]],' +
313
+ '"729",' +
314
+ '[["784"],"841",["900","961"]]]'
315
+ ) { throw r }
316
+ }
317
+ {
318
+ _map = remove(_map)("729")
319
+ if (_map === undefined) { throw 'undefined' }
320
+ const r = jsonStr(_map)
321
+ if (r !==
322
+ '[[["1024"],"1089",["1156","1225"],"1296",["1369","1444"]],' +
323
+ '"784",' +
324
+ '[["841"],"900",["961"]]]'
325
+ ) { throw r }
326
+ }
327
+ {
328
+ _map = remove(_map)("784")
329
+ if (_map === undefined) { throw 'undefined' }
330
+ const r = jsonStr(_map)
331
+ if (r !==
332
+ '[[["1024"],"1089",["1156","1225"]],"1296",[["1369","1444"],"841",["900","961"]]]'
333
+ ) { throw r }
334
+ }
335
+ {
336
+ _map = remove(_map)("841")
337
+ if (_map === undefined) { throw 'undefined' }
338
+ const r = jsonStr(_map)
339
+ if (r !==
340
+ '[[["1024"],"1089",["1156","1225"]],"1296",[["1369","1444"],"900",["961"]]]'
341
+ ) { throw r }
342
+ }
343
+ {
344
+ _map = remove(_map)("900")
345
+ if (_map === undefined) { throw 'undefined' }
346
+ const r = jsonStr(_map)
347
+ if (r !==
348
+ '[[["1024"],"1089",["1156","1225"]],"1296",[["1369"],"1444",["961"]]]'
349
+ ) { throw r }
350
+ }
351
+ {
352
+ _map = remove(_map)("961")
353
+ if (_map === undefined) { throw 'undefined' }
354
+ const r = jsonStr(_map)
355
+ if (r !==
356
+ '[["1024"],"1089",["1156","1225"],"1296",["1369","1444"]]'
357
+ ) { throw r }
358
+ }
359
+ {
360
+ _map = remove(_map)("1024")
361
+ if (_map === undefined) { throw 'undefined' }
362
+ const r = jsonStr(_map)
363
+ if (r !==
364
+ '[["1089"],"1156",["1225"],"1296",["1369","1444"]]'
365
+ ) { throw r }
366
+ }
367
+ {
368
+ _map = remove(_map)("1089")
369
+ if (_map === undefined) { throw 'undefined' }
370
+ const r = jsonStr(_map)
371
+ if (r !==
372
+ '[["1156","1225"],"1296",["1369","1444"]]'
373
+ ) { throw r }
374
+ }
375
+ {
376
+ _map = remove(_map)("1156")
377
+ if (_map === undefined) { throw 'undefined' }
378
+ const r = jsonStr(_map)
379
+ if (r !==
380
+ '[["1225"],"1296",["1369","1444"]]'
381
+ ) { throw r }
382
+ }
383
+ {
384
+ _map = remove(_map)("1225")
385
+ if (_map === undefined) { throw 'undefined' }
386
+ const r = jsonStr(_map)
387
+ if (r !==
388
+ '[["1296"],"1369",["1444"]]'
389
+ ) { throw r }
390
+ }
391
+ {
392
+ _map = remove(_map)("1296")
393
+ if (_map === undefined) { throw 'undefined' }
394
+ const r = jsonStr(_map)
395
+ if (r !==
396
+ '["1369","1444"]'
397
+ ) { throw r }
398
+ }
399
+ {
400
+ _map = remove(_map)("1369")
401
+ if (_map === undefined) { throw 'undefined' }
402
+ const r = jsonStr(_map)
403
+ if (r !== '["1444"]') { throw r }
404
+ }
405
+ {
406
+ _map = remove(_map)("1444")
407
+ if (_map !== undefined) { throw _map }
408
+ }
409
+ }
@@ -7,6 +7,7 @@ const list = require('../list')
7
7
 
8
8
  require('./find/test')
9
9
  require('./set/test')
10
+ require('./remove/test')
10
11
 
11
12
  const jsonStr = json.stringify(sort)
12
13