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.
empty?
(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
len
(Fn [(Ref (Hompair (Size (Size Zero)) a) b)] Int)
(len pair)
Returns the length of a Hompair.
(len (Hompair.of 1 1))
=> 2
lookup
(Fn [(Hompair (Size (Size Zero)) a)] (Fn [(Index (Hompair (Size (Size Zero)) Opaque) Int)] a))
(lookup pair)
map
(Fn [(Ref (Fn [a] b) c), (Ref (Hompair (Size (Size Zero)) a) d)] (Hompair (Size (Size Zero)) b))
(map f pair)
nth
(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
(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
(Fn [] (Hompair (Size (Size Zero)) (Index (Hompair (Size (Size Zero)) Opaque) Int)))
(positions)
replicate
(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)
set-first!
(Fn [(Ref (Hompair a b) c), b] ())
sets the first
property of a Hompair
in place.
set-second!
(Fn [(Ref (Hompair a b) c), b] ())
sets the second
property of a Hompair
in place.
swap
(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
(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
(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
(Fn [] (Hompair (Size (Size Zero)) a))
(zero)
Returns a Hompair of the zero values of a given type.