Skip to content

Instantly share code, notes, and snippets.

@ndonolli
Created August 11, 2020 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ndonolli/8522e07f58c17b5ee54bb1f92ae2715a to your computer and use it in GitHub Desktop.
Save ndonolli/8522e07f58c17b5ee54bb1f92ae2715a to your computer and use it in GitHub Desktop.
factors->string
(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