1
0
mirror of https://github.com/alice-lg/alice-lg.git synced 2024-05-11 05:55:03 +00:00
2018-10-22 15:13:47 +02:00

29 lines
436 B
JavaScript

/**
* Intersect lists: [x | x <- A, x `elem` B]
*/
export function intersect(a, b) {
let res = [];
for (const e of a) {
for (const k of b) {
if (e==k) {
res.push(e);
break;
}
}
}
return res;
}
/**
* Resolve list with dict: [dict[x]||x | x <- L]
*/
export function resolve(dict, list) {
let result = [];
for (const e of list) {
result.push(dict[e]||e);
}
return result;
}