반응형

lang/node 63

javascript: 교집합(Union), 합집합(Intersection), 여집합(difference, minus)

ECMAScript 6 sets: union, intersection, difference [itertools — Functions creating iterators for efficient looping](https://docs.python.org/3/library/itertools.html] Union let a = new Set([1,2,3]); let b = new Set([4,3,2]); let union = new Set([...a, ...b]); // {1,2,3,4} Intersection let a = new Set([1,2,3]); let b = new Set([4,3,2]); let intersection = new Set( [...a].filter(x => b.has(x))); //..

lang/node 2021.01.21
반응형