No matching definitions.

tur/set

stdlib/set.tur

typed Set[A]: persistent set backed by the HAMT.

Since: Phase TC2-C

defstruct

Set

(defstruct Set [A])

parameterized persistent set with element type A.

Since: Phase TC2

defn

set-new

(set-new)

create a new empty Set[A].

An empty Set[A].

(set-new)  ; => empty Set

Since: Phase TC2

defn

set-add

(set-add [s :int h :int x :int])

add element x to the set; returns a new set.

sSet[A]
hprecomputed hash of x (from Hash[A] typeclass)
xelement to add (type A)

A new Set[A] containing x.

(set-add my-set (hash 42) 42)  ; => set with 42

Since: Phase TC2

defn

set-remove

(set-remove [s :int h :int x :int])

remove element x from the set; returns a new set.

sSet[A]
hprecomputed hash of x
xelement to remove (type A)

A new Set[A] without x.

(set-remove my-set (hash 42) 42)  ; => set without 42

Since: Phase TC2

defn

set-member?

(set-member? [s :int h :int x :int])

check whether element x is in the set.

sSet[A]
hprecomputed hash of x
xelement to test (type A)

true if x is in the set, false otherwise.

(set-member? my-set (hash 42) 42)  ; => true

Since: Phase TC2

defn

set-count

(set-count [s :int])

return the number of elements in the set.

sSet[A]

Integer count of elements.

(set-count my-set)  ; => 3

Since: Phase TC2

defn

set-union

(set-union [a :int b :int])

compute the union of two sets.

afirst Set[A]
bsecond Set[A]

A new Set[A] containing all elements from both sets.

(set-union set-a set-b)  ; => union set

Since: Phase TC2

defn

set-intersect

(set-intersect [a :int b :int])

compute the intersection of two sets.

afirst Set[A]
bsecond Set[A]

A new Set[A] containing only elements present in both a and b.

(set-intersect set-a set-b)  ; => intersection set

Since: Phase TC2

defn

set-diff

(set-diff [a :int b :int])

compute set difference a \ b (elements in a but not b).

aSet[A] (base set)
bSet[A] (elements to remove)

A new Set[A] with elements of a that are not in b.

(set-diff set-a set-b)  ; => difference set

Since: Phase TC2

defn

set-eq?

(set-eq? [a :int b :int])

compare two sets for equality.

afirst Set[A]
bsecond Set[A]

true if both sets contain exactly the same elements.

(set-eq? set-a set-b)  ; => true

Since: Phase TC2

defn

set-eq-cmp?

(set-eq-cmp? [a :int b :int cmp-fn])

structural equality with a user-supplied element

aSet[A]
bSet[A]
cmp-fncomparator fn [a :int b :int] :bool applied to element pairs

true iff both sets have the same count and every element of `a` has at least one structurally-equal counterpart in `b` per cmp-fn.

Since: Phase F3-5 (cross-plan-followups)

defn

set-free

(set-free [s :int])

free the Set wrapper struct.

sSet[A] to free
(set-free my-set)

Since: Phase TC2

definstance

Eq[Set]

(definstance Eq [Set])

membership equality using the HAMT structure.