Last active
May 27, 2021 02:24
-
-
Save kannangce/5d44fb380582bd8d99bda3b0b9a4d34f to your computer and use it in GitHub Desktop.
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
;; 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