tur/pair

stdlib/pair.tur
defstruct

Pair

(defstruct Pair [first :int second :int])
defn

pair-new

(pair-new [a b] :int)

allocate a new Pair on the heap.

afirst element (int64_t)
bsecond element (int64_t)

Since: Phase B1

defn

pair-first

(pair-first [p] :int)

return the first element of a Pair.

ppointer to a Pair (as int64_t)

Since: Phase B1

defn

pair-second

(pair-second [p] :int)

return the second element of a Pair.

ppointer to a Pair (as int64_t)

Since: Phase B1

defn

pair-free

(pair-free [p])

free a heap-allocated Pair (shallow free only).

ppointer to a Pair (as int64_t)

Since: Phase B1

definstance

Bifunctor[Pair]

(definstance Bifunctor [Pair])

bimap applies fn-left to first and fn-right to second.

defn

pair-eq?

(pair-eq? [p1 p2 cmp-fn] :bool)

compare two Pairs element-wise using a comparator function.

p1first Pair pointer (as int64_t)
p2second Pair pointer (as int64_t)
cmp-fncomparator fn [a :int b :int] :bool applied to each field

Since: Phase E1

definstance

Eq[Pair]

(definstance Eq [Pair])

eq? compares two Pairs using integer equality on each field.

definstance

Clone[Pair]

(definstance Clone [Pair])

clone deep-copies the Pair struct into a new heap allocation.

Internal definitions
__bifunctor_pair_bimap-- apply fn-left to first and fn-right to second, returning a new Pair.