Hompair

Hompairs are sized pairs of values of the same type.

Since all Hompairs are pairs of values, their size is fixed; they always have a Size of 2.

Hompairs implement the dimensional interfaces.

copy

template

(Fn [(Ref (Hompair a b) c)] (Hompair a b))

copies the Hompair.

delete

template

(Fn [(Hompair a b)] ())

deletes a Hompair. Should usually not be called manually.

empty?

defn

(Fn [(Ref (Hompair (Size (Size Zero)) a) b)] Bool)

                    (empty? pair)
                

Returns false. Hompairs may never be empty by definition.

(empty? &(Hompair.of 1 1))
=> false

first

instantiate

(Fn [(Ref (Hompair a b) c)] (Ref b c))

gets the first property of a Hompair.

len

defn

(Fn [(Ref (Hompair (Size (Size Zero)) a) b)] Int)

                    (len pair)
                

Returns the length of a Hompair.

(len (Hompair.of 1 1))
=> 2

lookup

defn

(Fn [(Hompair (Size (Size Zero)) a)] (Fn [(Index (Hompair (Size (Size Zero)) Opaque) Int)] a))

                    (lookup pair)
                

map

defn

(Fn [(Ref (Fn [a] b) c), (Ref (Hompair (Size (Size Zero)) a) d)] (Hompair (Size (Size Zero)) b))

                    (map f pair)
                

nth

defn

(Fn [(Ref (Hompair (Size (Size Zero)) a) b), (Index (Hompair (Size (Size Zero)) Opaque) Int)] a)

                    (nth pair index)
                

Retrieves the nth value from a Hompair using the int value of index. If n is greater than or equal 1, returns the second member of the Hompair.

(nth &(Hompair 1 2) (Index.init 0))
=> 1

of

defn

(Fn [a, a] (Hompair (Size (Size Zero)) a))

                    (of x y)
                

Constructs a new Hompair from values x and y.

(Hompair.of 2 4)
=> (Hompair 2 4)

positions

defn

(Fn [] (Hompair (Size (Size Zero)) (Index (Hompair (Size (Size Zero)) Opaque) Int)))

                    (positions)
                

prn

template

(Fn [(Ref (Hompair a b) c)] String)

converts a Hompair to a string.

ref=

defn

(Fn [(Ref (Hompair a b) c), (Ref (Hompair d b) e)] Bool)

                    (ref= pair other-pair)
                

replicate

defn

(Fn [a] (Hompair (Size (Size Zero)) a))

                    (replicate x)
                

Creates a new Hompair with x as both of its members.

(Hompair.replicate 1)
=> (Hompair 1 1)

second

instantiate

(Fn [(Ref (Hompair a b) c)] (Ref b c))

gets the second property of a Hompair.

set-first

template

(Fn [(Hompair a b), b] (Hompair a b))

sets the first property of a Hompair.

set-first!

template

(Fn [(Ref (Hompair a b) c), b] ())

sets the first property of a Hompair in place.

set-second

template

(Fn [(Hompair a b), b] (Hompair a b))

sets the second property of a Hompair.

set-second!

template

(Fn [(Ref (Hompair a b) c), b] ())

sets the second property of a Hompair in place.

str

template

(Fn [(Ref (Hompair a b) c)] String)

converts a Hompair to a string.

swap

defn

(Fn [(Ref (Hompair (Size (Size Zero)) a) b)] (Hompair (Size (Size Zero)) a))

                    (swap pair)
                

Swaps the position of each value in a Hompair.

(swap &(Hompair.of 1 2))
=> (Hompair 2 1)

update-first

instantiate

(Fn [(Hompair a b), (Ref (Fn [b] b c) d)] (Hompair a b))

updates the first property of a Hompair using a function f.

update-second

instantiate

(Fn [(Hompair a b), (Ref (Fn [b] b c) d)] (Hompair a b))

updates the second property of a Hompair using a function f.

zero

defn

(Fn [] (Hompair (Size (Size Zero)) a))

                    (zero)
                

Returns a Hompair of the zero values of a given type.