javascript - Console is displaying code content instead of executing it -
i modify function collecting array difference here handle multi-dimensional array, code not working expected , debugging has been problematic because console.log displaying content of code instead of executing it...
function arrdiff(xs, yx, d) { const apply = f => x => f(x); const flip = f => y => x => f(x)(y); const concat = y => xs => xs.concat(y); const createmap = xs => new map(xs); const filter = f => xs => xs.filter(apply(f)); //left difference const differencel = xs => yx => { const zs = createmap(yx); return filter(([k, x]) => zs.has(x) ? false : true)(xs); }; if (d == 'left') return differencel //right difference const difference2 = flip(differencel); if (d == 'join') return difference2; //union if (d == "union") { const map = new map([...xs, ...yx]); return map; } // symmetric difference const difference = yx => xs => concat(differencel(xs)(yx)) (flip(differencel)(xs)(yx)); return difference; } const xs = [ ['a', 1], ['b', 2], ['c', 2], ['d', 3], ['e', 4], ['f', 5] ]; const ys = [ ['g', 0], ['h', 1], ['f', 2], ['b', 3], ['c', 3], ['a', 3], ['e', 6], ['h', 7] ]; console.log(arrdiff(xs, ys, 'left'));
Comments
Post a Comment