Method on @sym: intersect (A, B)

Return the common elements of two sets.

Example:

A = finiteset(sym(1), 2, 3);
B = finiteset(sym(pi), 2);
intersect(A, B)
  ⇒ ans = (sym) {2}

The sets can also be intervals or a mixture of finite sets and intervals:

C = interval(sym(2), 10);
intersect(A, C)
  ⇒ ans = (sym) {2, 3}

D = interval(0, sym(pi));
intersect(C, D)
  ⇒ ans = (sym) [2, π]

See also: @sym/union, @sym/setdiff, @sym/setxor, @sym/unique, @sym/ismember, @sym/finiteset, @sym/interval.

Package: symbolic