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
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
| Name | Type | Description |
|---|---|---|
x | Expression | Vector | ValuesSet | Dictionary | SolutionSet | Vector, finite set, solution set, or dictionary to search. |
value | ExpressionInput | Value to look up, or dictionary key when `x` is a Dictionary. |
Returns
Expression — `1` when the value is found and `0` otherwise.
