Printing n numbers in Clojure
Somewhere I saw a question where one needs to print from 1 to a number in Clojure, and this is a way it could be done:
;; print-n-numbers.clj (require '[clojure.string :as string]) (let [number 10] ; setting variable number (println ; let's print the joined sequence (string/join "\n" ; joining the range with newline character (range ; let's create a range from 1 to the number 1 (+ 1 number)))))
What I like in the above code is this line
(require '[clojure.string :as string])
Here we can kind of rename
string and use it in the program. I hope the added comments is sufficient enough to make one understand this code, any way I have plns to convert this blog to video series and in it I will explain how to code in Clojure in detail.