Function reference · Math

contains

Returns 1 if a vector, set, solution set or dictionary contains a value, and 0 otherwise.

For a dictionary it checks the keys. For anything else, the call is returned unevaluated.

Notation

contains(x, value)

Write it in an expression: nerdamer('contains([x,1,2],1)'), or in the Playground.

nerdamer.contains

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

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

Examples

In a vector.

contains([x,1,2],1)
// → 1
Open in Playground

Not in it.

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

A dictionary key.

contains({a=>1},a)
// → 1
Open in Playground

Deprecated names

Deprecated.

is_in still works, and gives the same result as contains, but each call records an api.deprecatedFunction warning. Use contains instead; the old name will be removed in a later major version.

← Back to Function reference