File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717 (defn lookup [pair] (fn [i] (Hompair.nth &pair i)))
1818
1919 (sig map
20- (Fn [(Ref (Fn [a] b)) (Ref (Hompair (Size.size 2) a))]
21- (Hompair (Size.size 2) b)))
20+ (Fn
21+ [(Ref (Fn [a] b)) (Ref (Hompair (Size.size 2) a))]
22+ (Hompair (Size.size 2) b)))
2223 (implements smap map)
2324 (defn map [f pair]
2425 (let [first (~f @(Hompair.first pair))
Original file line number Diff line number Diff line change 88 ""
99 "Hompairs implement the [dimensional interfaces](dimensional.html).")
1010(deftype (Hompair s a) [first a
11- second a])
11+ second a])
1212(hidden Hompair.init)
1313(private Hompair.init)
1414
4444 "=> 1"
4545 "```")
4646 (sig nth
47- (Fn [
48- (Ref (Hompair (Size.size 2) a))
49- (Index (Hompair (Size.size 2) Opaque) Int)]
50- a))
47+ (Fn
48+ [ (Ref (Hompair (Size.size 2) a))
49+ (Index (Hompair (Size.size 2) Opaque) Int)]
50+ a))
5151 (defn nth [pair index]
5252 (if (= 0 (to-int &index)) @(Hompair.first pair) @(Hompair.second pair)))
5353
9191
9292 (implements = ref=)
9393 (defn ref= [pair other-pair]
94- (and (= @(Hompair.first pair) @(Hompair.first other-pair))
95- (= @(Hompair.second pair) @(Hompair.second other-pair)))))
94+ (and
95+ (= @(Hompair.first pair) @(Hompair.first other-pair))
96+ (= @(Hompair.second pair) @(Hompair.second other-pair)))))
Original file line number Diff line number Diff line change 4040
4141 (doc zip "Combines two Vectors using a binary function `f`.")
4242 (sig zip
43- (Fn [(Ref (Fn [a b] c)) (Ref (Vector n a)) (Ref (Vector n b))]
44- (Vector n c)))
43+ (Fn
44+ [(Ref (Fn [a b] c)) (Ref (Vector n a)) (Ref (Vector n b))]
45+ (Vector n c)))
4546 (defn zip [f v v1]
4647 (let [copy-then-apply (fn [a b] (~f @a @b))
4748 arr (Vector.elements v)
6465 (sig last (Fn [(Ref (Vector (Size n) a))] a))
6566 (defn last [v]
6667 @(Array.unsafe-nth (Vector.elements v)
67- (to-int (the (Phantom n) (Phantom.init)))))
68+ (to-int (the (Phantom n) (Phantom.init)))))
6869
6970 (doc head "Returns the first element of a Vector.")
7071 (sig head (Fn [(Ref (Vector (Size n) a))] a))
7172 (defn head [v]
7273 @(Array.unsafe-nth (Vector.elements v)
73- (to-int (the (Phantom Zero) (Phantom.init)))))
74+ (to-int (the (Phantom Zero) (Phantom.init)))))
7475
7576 (hidden gen-vec)
7677 (defndynamic gen-vec [vs acc]
7778 (if (= 0 (length vs))
7879 acc
7980 (Vector.gen-vec (cdr vs)
80- (cons-last (list 'Vector.push (car vs)) (cons-last '(ref) acc)))))
81+ (cons-last (list 'Vector.push (car vs))
82+ (cons-last '(ref) acc)))))
8183
8284 (doc of "Creates a new Vector from the contents of an Array literal.")
8385 (defmacro of [values]
Original file line number Diff line number Diff line change 1414 "lookup returns the element at a given index")
1515 (assert-equal test
1616 &(Vector.of [(Vector.of [1 3 5]) (Vector.of [2 4 6])])
17- &(Dimensional.transpose &(Vector.of [
18- (Vector.of [1 2])
19- (Vector.of [3 4])
20- (Vector.of [5 6])]))
17+ &(Dimensional.transpose
18+ &(Vector.of [(Vector.of [1 2]) (Vector.of [3 4]) (Vector.of [5 6])]))
2119 "transpose swaps the sizes of a Vector of Vectors"))
You can’t perform that action at this time.
0 commit comments