Skip to content

Instantly share code, notes, and snippets.

@kannangce
Last active May 27, 2021 02:24
Show Gist options
  • Save kannangce/5d44fb380582bd8d99bda3b0b9a4d34f to your computer and use it in GitHub Desktop.
Save kannangce/5d44fb380582bd8d99bda3b0b9a4d34f to your computer and use it in GitHub Desktop.
;; The below macro could have been simple function. Keeping it for reference though
(defmacro create-matrix
"Clojure macro to create a matrix with any number of dimension"
([x & dim]
(loop [ex ['->> x] d dim]
(if (empty? d)
(apply list ex)
(recur (into ex [`(repeat ~(first d)) 'vec])
(rest d)))
))
([] nil)
([x] nil))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment