symmetricDifference.js 910 B

1234567891011121314151617181920212223242526272829
  1. import _curry2 from "./internal/_curry2.js";
  2. import concat from "./concat.js";
  3. import difference from "./difference.js";
  4. /**
  5. * Finds the set (i.e. no duplicates) of all elements contained in the first or
  6. * second list, but not both.
  7. *
  8. * @func
  9. * @memberOf R
  10. * @since v0.19.0
  11. * @category Relation
  12. * @sig [*] -> [*] -> [*]
  13. * @param {Array} list1 The first list.
  14. * @param {Array} list2 The second list.
  15. * @return {Array} The elements in `list1` or `list2`, but not both.
  16. * @see R.symmetricDifferenceWith, R.difference, R.differenceWith
  17. * @example
  18. *
  19. * R.symmetricDifference([1,2,3,4], [7,6,5,4,3]); //=> [1,2,7,6,5]
  20. * R.symmetricDifference([7,6,5,4,3], [1,2,3,4]); //=> [7,6,5,1,2]
  21. */
  22. var symmetricDifference =
  23. /*#__PURE__*/
  24. _curry2(function symmetricDifference(list1, list2) {
  25. return concat(difference(list1, list2), difference(list2, list1));
  26. });
  27. export default symmetricDifference;