a few more options for main

This commit is contained in:
mehbark 2023-01-16 17:10:25 -05:00
parent c94f1b2169
commit 5068304b7c
3 changed files with 29 additions and 4 deletions

View file

@ -51,6 +51,7 @@
(let [steps (gaussian-column m col)
new (apply-all-at-once m steps)]
(concat steps (gaussian-elim new (inc col)))))))
; TODO: if you can just divide to make a row good, do
(defn back-sub-column
[m col]

View file

@ -6,16 +6,34 @@
(:require [matrix.render :refer :all])
(:gen-class))
(defn -main
"I don't do a whole lot ... yet."
[& args]
(defn steps-final-equations-interactive
[]
(let [[steps final] (auto-steps-and-final (read))]
(println "Steps:")
;; (for [step steps]
;; (println (pretty-row-op step)))
(println (str/join "\n" (map with-inc-row-indices steps)))
(println "Final:")
(pprint-matrix final)))
(pprint-matrix final :with-bar)
(println (equations final))))
(defn steps-with-matrices
[]
(let [got (read)
[steps final] (auto-steps-and-final got)]
(->> steps
(apply-steps got)
(cons got)
(map #(pretty-matrix % true))
(#(interleave % (map pretty-row-op steps)))
(#(concat % [(pretty-matrix final true)]))
(str/join "\n")
println)))
(defn -main
"I don't do a whole lot ... yet."
[& args]
(steps-final-equations-interactive))
; TODO: actual parsing of row operations
; TODO: parse equations (easy, but requires context (e.g. x = 1 could be any number of variables))

View file

@ -132,6 +132,12 @@
(if (not-empty z) " ")
"= " eq))))
(defn equations
"Write an equation for each row of an augmented matrix"
[m]
(str/join "\n"
(map equation-from-row m)))
(defn shrink-digit
"Takes a digit and returns the subscript version"
[d]