Making foo bar more readable in Clojure

less than 1 minute read

Notes

;; foo_bar_redable.clj

(defn divisible?
  "
   if x is divisble by y, it returns true
  "
  [x y]
  (when (= (mod x y) 0) true))

(defn foo [number]
  (if (divisible? number 3) 
    "foo"
    ""))

(defn bar [number]
  (if (divisible? number 5) 
    "bar"
    ""))

(defn foobar-string [number]
  (str number " - " (foo number) " " (bar number) "\n"))

(println
 (map foobar-string (range 1 31)))

Updated: