-
Notifications
You must be signed in to change notification settings - Fork 4
/
assoc-list.optimized.js
312 lines (289 loc) · 6.81 KB
/
assoc-list.optimized.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
var pzp1997$assoc_list$AssocList$D = elm$core$Basics$identity;
var pzp1997$assoc_list$AssocList$empty = _List_Nil;
var pzp1997$assoc_list$AssocList$get = F2(
function (targetKey, _n0) {
get:
while (true) {
var alist = _n0;
if (!alist.b) {
return elm$core$Maybe$Nothing;
} else {
var _n2 = alist.a;
var key = _n2.a;
var value = _n2.b;
var rest = alist.b;
if (_Utils_eq(key, targetKey)) {
return elm$core$Maybe$Just(value);
} else {
var $temp$targetKey = targetKey,
$temp$_n0 = rest;
targetKey = $temp$targetKey;
_n0 = $temp$_n0;
continue get;
}
}
}
});
var pzp1997$assoc_list$AssocList$member = F2(
function (targetKey, dict) {
var _n0 = A2(pzp1997$assoc_list$AssocList$get, targetKey, dict);
if (!_n0.$) {
return true;
} else {
return false;
}
});
var pzp1997$assoc_list$AssocList$size = function (_n0) {
var alist = _n0;
return elm$core$List$length(alist);
};
var pzp1997$assoc_list$AssocList$isEmpty = function (dict) {
return _Utils_eq(dict, _List_Nil);
};
var pzp1997$assoc_list$AssocList$eq = F2(
function (leftDict, rightDict) {
return A6(
pzp1997$assoc_list$AssocList$merge,
F3(
function (_n0, _n1, _n2) {
return false;
}),
F4(
function (_n3, a, b, result) {
return result && _Utils_eq(a, b);
}),
F3(
function (_n4, _n5, _n6) {
return false;
}),
leftDict,
rightDict,
true);
});
var pzp1997$assoc_list$AssocList$insert = F3(
function (key, value, dict) {
var _n0 = A2(pzp1997$assoc_list$AssocList$remove, key, dict);
var alteredAlist = _n0;
return A2(
elm$core$List$cons,
_Utils_Tuple2(key, value),
alteredAlist);
});
var pzp1997$assoc_list$AssocList$remove = F2(
function (targetKey, _n0) {
var alist = _n0;
return A2(
elm$core$List$filter,
function (_n1) {
var key = _n1.a;
return !_Utils_eq(key, targetKey);
},
alist);
});
var pzp1997$assoc_list$AssocList$update = F3(
function (targetKey, alter, dict) {
var alist = dict;
var maybeValue = A2(pzp1997$assoc_list$AssocList$get, targetKey, dict);
if (!maybeValue.$) {
var _n1 = alter(maybeValue);
if (!_n1.$) {
var alteredValue = _n1.a;
return A2(
elm$core$List$map,
function (entry) {
var key = entry.a;
return _Utils_eq(key, targetKey) ? _Utils_Tuple2(targetKey, alteredValue) : entry;
},
alist);
} else {
return A2(pzp1997$assoc_list$AssocList$remove, targetKey, dict);
}
} else {
var _n2 = alter(elm$core$Maybe$Nothing);
if (!_n2.$) {
var alteredValue = _n2.a;
return A2(
elm$core$List$cons,
_Utils_Tuple2(targetKey, alteredValue),
alist);
} else {
return dict;
}
}
});
var pzp1997$assoc_list$AssocList$singleton = F2(
function (key, value) {
return _List_fromArray(
[
_Utils_Tuple2(key, value)
]);
});
var pzp1997$assoc_list$AssocList$union = F2(
function (_n0, rightDict) {
var leftAlist = _n0;
return A3(
elm$core$List$foldr,
F2(
function (_n1, result) {
var lKey = _n1.a;
var lValue = _n1.b;
return A3(pzp1997$assoc_list$AssocList$insert, lKey, lValue, result);
}),
rightDict,
leftAlist);
});
var pzp1997$assoc_list$AssocList$intersect = F2(
function (_n0, rightDict) {
var leftAlist = _n0;
return A2(
elm$core$List$filter,
function (_n1) {
var key = _n1.a;
return A2(pzp1997$assoc_list$AssocList$member, key, rightDict);
},
leftAlist);
});
var pzp1997$assoc_list$AssocList$diff = F2(
function (_n0, rightDict) {
var leftAlist = _n0;
return A2(
elm$core$List$filter,
function (_n1) {
var key = _n1.a;
return !A2(pzp1997$assoc_list$AssocList$member, key, rightDict);
},
leftAlist);
});
var pzp1997$assoc_list$AssocList$merge = F6(
function (leftStep, bothStep, rightStep, leftDict, _n0, initialResult) {
var leftAlist = leftDict;
var rightAlist = _n0;
var _n1 = A2(
elm$core$List$partition,
function (_n2) {
var key = _n2.a;
return A2(pzp1997$assoc_list$AssocList$member, key, leftDict);
},
rightAlist);
var inBothAlist = _n1.a;
var inRightOnlyAlist = _n1.b;
var intermediateResult = A3(
elm$core$List$foldr,
F2(
function (_n5, result) {
var rKey = _n5.a;
var rValue = _n5.b;
return A3(rightStep, rKey, rValue, result);
}),
initialResult,
inRightOnlyAlist);
return A3(
elm$core$List$foldr,
F2(
function (_n3, result) {
var lKey = _n3.a;
var lValue = _n3.b;
var _n4 = A2(pzp1997$assoc_list$AssocList$get, lKey, inBothAlist);
if (!_n4.$) {
var rValue = _n4.a;
return A4(bothStep, lKey, lValue, rValue, result);
} else {
return A3(leftStep, lKey, lValue, result);
}
}),
intermediateResult,
leftAlist);
});
var pzp1997$assoc_list$AssocList$map = F2(
function (alter, _n0) {
var alist = _n0;
return A2(
elm$core$List$map,
function (_n1) {
var key = _n1.a;
var value = _n1.b;
return _Utils_Tuple2(
key,
A2(alter, key, value));
},
alist);
});
var pzp1997$assoc_list$AssocList$foldl = F3(
function (func, initialResult, _n0) {
var alist = _n0;
return A3(
elm$core$List$foldl,
F2(
function (_n1, result) {
var key = _n1.a;
var value = _n1.b;
return A3(func, key, value, result);
}),
initialResult,
alist);
});
var pzp1997$assoc_list$AssocList$foldr = F3(
function (func, initialResult, _n0) {
var alist = _n0;
return A3(
elm$core$List$foldr,
F2(
function (_n1, result) {
var key = _n1.a;
var value = _n1.b;
return A3(func, key, value, result);
}),
initialResult,
alist);
});
var pzp1997$assoc_list$AssocList$filter = F2(
function (isGood, _n0) {
var alist = _n0;
return A2(
elm$core$List$filter,
function (_n1) {
var key = _n1.a;
var value = _n1.b;
return A2(isGood, key, value);
},
alist);
});
var pzp1997$assoc_list$AssocList$partition = F2(
function (isGood, _n0) {
var alist = _n0;
var _n1 = A2(
elm$core$List$partition,
function (_n2) {
var key = _n2.a;
var value = _n2.b;
return A2(isGood, key, value);
},
alist);
var good = _n1.a;
var bad = _n1.b;
return _Utils_Tuple2(good, bad);
});
var pzp1997$assoc_list$AssocList$keys = function (_n0) {
var alist = _n0;
return A2(elm$core$List$map, elm$core$Tuple$first, alist);
};
var pzp1997$assoc_list$AssocList$values = function (_n0) {
var alist = _n0;
return A2(elm$core$List$map, elm$core$Tuple$second, alist);
};
var pzp1997$assoc_list$AssocList$toList = function (_n0) {
var alist = _n0;
return alist;
};
var pzp1997$assoc_list$AssocList$fromList = function (alist) {
return A3(
elm$core$List$foldl,
F2(
function (_n0, result) {
var key = _n0.a;
var value = _n0.b;
return A3(pzp1997$assoc_list$AssocList$insert, key, value, result);
}),
_List_Nil,
alist);
};