Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
juerg committed Dec 18, 2023
1 parent d24fd06 commit 6e8d63f
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/main/resources/com/github/jlangch/venice/matrix.venice
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,12 @@
add-column-at-start [m c]

(validate m)
(as-> (map vector c m) mat
(map #(cons (first %) (second %)) mat)))
(if (empty? m)
(map #(vector %) c)
(do
(assert (= (count c) (rows m)) "The new column must have ~(rows m) rows")
(as-> (map vector c m) mat
(map #(cons (first %) (second %)) mat)))))


(defn
Expand All @@ -247,8 +251,12 @@
add-column-at-end [m c]

(validate m)
(as-> (map vector c m) mat
(map #(conj (second %) (first %)) mat)))
(if (empty? m)
(map #(vector %) c)
(do
(assert (= (count c) (rows m)) "The new column must have ~(rows m) rows")
(as-> (map vector c m) mat
(map #(conj (second %) (first %)) mat)))))


(defn
Expand All @@ -273,6 +281,8 @@
add-row-at-start [m r]

(validate m)
(when-not (empty? m)
(assert (= (count r) (columns m)) "The new row must have ~(columns m) columns"))
(cons r m))


Expand All @@ -298,6 +308,8 @@
add-row-at-end [m r]

(validate m)
(when-not (empty? m)
(assert (= (count r) (columns m)) "The new row must have ~(columns m) columns"))
(conj m r))


Expand Down

0 comments on commit 6e8d63f

Please sign in to comment.