Function reference · Math

contains

Tests membership in a supported finite container.

Vector membership compares elements, finite sets and solution sets use set membership, and Dictionary membership checks keys. The result is 1 when present and 0 when absent.

Unsupported container types remain as a symbolic contains(container,value) call.

Examples

These examples use Nerdamer Notation.

Find a value in a vector.

contains([x,1,2],1)
// → 1

Return zero when the value is absent.

contains([x,1,2],10)
// → 0

Interfaces

The same operation is available through the interfaces below.

Nerdamer Notation · nerdamer API

Nerdamer Notation

Use this form inside input passed to nerdamer(...).

contains(arg1, arg2)

nerdamer.contains

Call the operation through the default nerdamer import.

nerdamer.contains(x: Expression | Vector | ValuesSet | Dictionary | SolutionSet, value: ExpressionInput): Expression

Parameters

NameTypeDescription
xExpression | Vector | ValuesSet | Dictionary | SolutionSetVector, finite set, solution set, or dictionary to search.
valueExpressionInputValue to look up, or dictionary key when `x` is a Dictionary.

Returns

Expression — `1` when the value is found and `0` otherwise.

Browse the nerdamer API →

← Back to Reference