set/element-of

Usage

Description

Input

Output

Examples

True — element is in the set

False — element not in the set

Symbols or strings

Details

Errors

set/element-of

Membership inclusion test (element in set)

Usage

R:=set/element-of(x, S)R:=xS

Description

Determines whether an element x is a member of set S.

This function returns a boolean value indicating whether x exists within the set.

It wraps Rust's IndexSet membership check, returning true if the element is found.

Input

Arguments:

  • x : T — the element being tested for membership.

  • S : set of T — the set to test against.

Element type constraints:

  • T must be hashable and comparable for equality (Eq + Hash in Rust).

  • Common scalar kinds: integers, strings, symbols, booleans.

Output

Result:

  • R : boolean — true if x is an element of S, otherwise false.

Examples

True — element is in the set

x:="b"S:={"a", "b", "c"}R:=set/element-of(x, S)

False — element not in the set

x:=5S:={1, 2, 3, 4}R:=xS

Symbols or strings

x:=pearS:={apple, pear, banana}R:=set/element-of(x, S)

Details

Set semantics:

  • The set treats elements as unique based on hash and equality.

  • Duplicates are ignored in the set.

Relation logic:

  • Returns true if the element exists in the set.

Symbolic shorthand:

  • x ∈ S is equivalent to set/element-of(x, S).

Performance:

  • Average O(1) time per lookup using hashing.

Determinism:

  • Results are deterministic across runs and platforms.

Errors

  • Incorrect number of arguments (expects two).

  • Unsupported element type (not hashable or comparable).

  • Type mismatch between x and elements of S.