Function reference · Assumptions and sets

intersection

Returns the set of values that are in every one of the given sets.

Notation

intersection(set1, set2[, ...])

Write it in an expression: nerdamer('intersection({1,2,3},{2,3,4})'), or in the Playground.

nerdamer.intersection

nerdamer.intersection(...args: string | number | bigint | ParserEntity[]): ParserEntity

A method on the default import. Arguments can be strings, as in Notation.

import { intersection }

import { intersection } from 'nerdamer/structures';
intersection(...sets: ParserEntity[]): ParserEntity

Import only this function, from nerdamer/structures.

Parameters

set1, set2, ...
Two or more sets, written {...}.

Returns

A set, empty, {}, when no value is in all of them.

Examples

The values both sets share.

intersection({1,2,3},{2,3,4})
// → {2, 3}
Open in Playground

More than two sets.

intersection({a,b,c},{b,c},{c,d})
// → {c}
Open in Playground

Nothing in common gives the empty set.

intersection({1,2},{3})
// → {}
Open in Playground

Good to know

  • Every argument must be a set.

JavaScript examples

nerdamer.intersection('{1,2}', '{2,3}').text()
// → {2}

← Back to Function reference