Permalink
Browse files

Implemented wrap in terms of clojure.core/mod

  • Loading branch information...
bendlas committed Dec 12, 2011
1 parent a87319a commit 1b3aba10e4c6c39ba2e575fb60b9375b01a01b8e
Showing with 5 additions and 6 deletions.
  1. +5 −6 src/aichallenge/util.clj
View
@@ -2,13 +2,12 @@
(:use [clojure.pprint :only (pprint)]))
(defn wrap
- ([val upper] (wrap val 0 upper))
+ ([val upper]
+ (mod val (inc upper)))
([val lower upper]
- (let [l (inc (- upper lower))]
- (cond
- (< val lower) (recur (+ val l) lower upper)
- (< upper val) (recur (- val l) lower upper)
- :else val))))
+ (+ lower
+ (wrap (- val lower)
+ (- upper lower)))))
(defn perr [& strs]

0 comments on commit 1b3aba1

Please sign in to comment.