Sha256: cfb2b7fe9483696dfd02901998a588b1fc7c004713221c231d6e475321848f55

Contents?: true

Size: 597 Bytes

Versions: 300

Compression:

Stored size: 597 Bytes

Contents

(ns clock)

(defn clock
  "Return a 24 hour clock representation of the given hours and minutes."
  [in-hour in-minute]
  (let [total-minutes (mod (+ (* in-hour 60) in-minute) (* 60 24))
        hours (mod (quot total-minutes 60) 24)
        minutes (mod total-minutes 60)]
    {:hour hours :minute minutes}))

(defn clock->string
  "Print the HH:MM representation of a clock."
  [in-clock]
  (format "%02d:%02d" (:hour in-clock) (:minute in-clock)))

(defn add-time
  "Add minutes to the given clock."
  [in-clock minutes-to-add]
  (clock (:hour in-clock) (+ (:minute in-clock) minutes-to-add)))

Version data entries

300 entries across 300 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/clojure/exercises/clock/src/example.clj
trackler-2.2.1.179 tracks/clojure/exercises/clock/src/example.clj
trackler-2.2.1.178 tracks/clojure/exercises/clock/src/example.clj
trackler-2.2.1.177 tracks/clojure/exercises/clock/src/example.clj
trackler-2.2.1.176 tracks/clojure/exercises/clock/src/example.clj
trackler-2.2.1.175 tracks/clojure/exercises/clock/src/example.clj
trackler-2.2.1.174 tracks/clojure/exercises/clock/src/example.clj
trackler-2.2.1.173 tracks/clojure/exercises/clock/src/example.clj
trackler-2.2.1.172 tracks/clojure/exercises/clock/src/example.clj
trackler-2.2.1.171 tracks/clojure/exercises/clock/src/example.clj
trackler-2.2.1.170 tracks/clojure/exercises/clock/src/example.clj
trackler-2.2.1.169 tracks/clojure/exercises/clock/src/example.clj
trackler-2.2.1.167 tracks/clojure/exercises/clock/src/example.clj
trackler-2.2.1.166 tracks/clojure/exercises/clock/src/example.clj
trackler-2.2.1.165 tracks/clojure/exercises/clock/src/example.clj
trackler-2.2.1.164 tracks/clojure/exercises/clock/src/example.clj
trackler-2.2.1.163 tracks/clojure/exercises/clock/src/example.clj
trackler-2.2.1.162 tracks/clojure/exercises/clock/src/example.clj
trackler-2.2.1.161 tracks/clojure/exercises/clock/src/example.clj
trackler-2.2.1.160 tracks/clojure/exercises/clock/src/example.clj