Documentation moved.
This entry is now part of the unified function reference. Open the unified page →
Function
src/index.ts:818nerdamer.contains
nerdamer.contains(x: Expression | Vector | ValuesSet | Dictionary | SolutionSet, value: ExpressionInput): ExpressionTests whether a value is present in a supported finite container.
remarks
`Vector`membership uses the vector's element equality, while
`ValuesSet`and
`SolutionSet`delegate to their semantic set membership.
`Dictionary`membership checks keys rather than stored values. Unsupported container types remain symbolic.
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.
Examples
const d = Parser.parse('{x=>1, y=>a}') as Dictionary;
contains(d, 'x').text(); // 1
const v = new Vector(['x', 1, 2]);
contains(v, 10).text(); // 0