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.1.0.41 tracks/clojure/exercises/clock/src/example.clj
trackler-2.1.0.40 tracks/clojure/exercises/clock/src/example.clj
trackler-2.1.0.39 tracks/clojure/exercises/clock/src/example.clj
trackler-2.1.0.38 tracks/clojure/exercises/clock/src/example.clj
trackler-2.1.0.37 tracks/clojure/exercises/clock/src/example.clj
trackler-2.1.0.36 tracks/clojure/exercises/clock/src/example.clj
trackler-2.1.0.34 tracks/clojure/exercises/clock/src/example.clj
trackler-2.1.0.33 tracks/clojure/exercises/clock/src/example.clj
trackler-2.1.0.32 tracks/clojure/exercises/clock/src/example.clj
trackler-2.1.0.31 tracks/clojure/exercises/clock/src/example.clj
trackler-2.1.0.30 tracks/clojure/exercises/clock/src/example.clj
trackler-2.1.0.29 tracks/clojure/exercises/clock/src/example.clj
trackler-2.1.0.28 tracks/clojure/exercises/clock/src/example.clj
trackler-2.1.0.27 tracks/clojure/exercises/clock/src/example.clj
trackler-2.1.0.26 tracks/clojure/exercises/clock/src/example.clj
trackler-2.1.0.25 tracks/clojure/exercises/clock/src/example.clj
trackler-2.1.0.24 tracks/clojure/exercises/clock/src/example.clj
trackler-2.1.0.23 tracks/clojure/exercises/clock/src/example.clj
trackler-2.1.0.22 tracks/clojure/exercises/clock/src/example.clj
trackler-2.1.0.21 tracks/clojure/exercises/clock/src/example.clj