(ns robot-name)

(def ^:private random (java.util.Random.))
(def ^:private letters (map char (range 65 91)))
(defn- generate-name []
  (str (apply str (take 2 (shuffle letters)))
       (+ 100 (.nextInt random 899))))

(defn robot []
  (atom {:name (generate-name)}))

(defn robot-name [robot]
  (:name @robot))

(defn reset-name [robot]
  (swap! robot assoc :name (generate-name)))

(ns robot-name)

(def ^:private letters (map char (range 65 91)))
(defn- generate-name []
  (format "%s%03d" (apply str (repeatedly 2 #(first (shuffle letters))))
          (rand-int 1000)))

(defn robot []
  (atom {:name (generate-name)}))

(defn robot-name [robot]
  (:name @robot))

(defn reset-name [robot]
  (swap! robot assoc :name (generate-name)))

Simplify generate-name function for robot-name
Simplify generate-name function for robot-name

This commit updates the generate-name function in robot-name to use
clojure's rand-int function instead of java interop. It also updates the
rand-int call to include all of the range 0-999 and refactors the string
assembly somewhat.

exercism/xclojure,exercism/xclojure,querenker/xclojure,querenker/xclojure