Generating multiplication tables with Clojure

less than 1 minute read

Code

(defn single-line [number multiplicant]
  (str
   number " X " multiplicant " = " (* number multiplicant)))

;; (def num 5)

;; (println
;;  (clojure.string/join "\n"
;;                      (map single-line (repeat 10 5) (range 1 11))))

(defn single-table [number]
  (clojure.string/join "\n"
                       (map single-line (repeat 10 number) (range 1 11))))


(println (clojure.string/join "\n\n\n" (map single-table (range 1 21))))

Updated: