add human-readable indices (starting at 1)

This commit is contained in:
mehbark 2023-01-15 20:31:36 -05:00
parent 3b998c060b
commit b414870e70
3 changed files with 20 additions and 7 deletions

View file

@ -68,7 +68,6 @@
[]
(let [steps (back-sub-column m col)
new (apply-all-at-once m steps)]
(println new)
(concat steps (back-sub new (dec col)))))))
(defn auto-steps-and-final

View file

@ -13,7 +13,7 @@
(println "Steps:")
;; (for [step steps]
;; (println (pretty-row-op step)))
(println (str/join "\n" (map pretty-row-op steps)))
(println (str/join "\n" (map with-inc-row-indices steps)))
(println "Final:")
(pprint-matrix final)))

View file

@ -169,11 +169,25 @@
" + "
"R" (shrink-number (:to-row op)))))
(defn with-inc-row-indices
"Prettify a row-op with human-readable-indices"
[op]
(if-let [[op-type inner] (conform op)]
(case op-type
:swap (pretty-swap (-> inner
(update :swap + 1)
(update :with + 1)))
:add (pretty-add (-> inner
(update :add-row + 1)
(update :to-row + 1)))
:mul (pretty-mul (update inner :mul-row + 1)))))
(defn pretty-row-op
"Returns a pretty string of a row operation"
[op]
([op]
(if-let [[op-type inner] (conform op)]
(case op-type
:swap (pretty-swap inner)
:mul (pretty-mul inner)
:add (pretty-add inner))))
([op _] (with-inc-row-indices op)))