Created
August 11, 2020 17:55
-
-
Save ndonolli/8522e07f58c17b5ee54bb1f92ae2715a to your computer and use it in GitHub Desktop.
factors->string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn factors->string [factors] | |
(->> (frequencies factors) | |
(map (fn [[n exp]] | |
(if (= 1 exp) (str n) (str n "^" exp)))) | |
(interpose " x ") | |
(cons (str (apply * factors) " = ")) | |
(apply str))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment