Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defn adjust-index
- ([vector index]
- (cond (neg? index) (+ (count vector) index)
- (<= (count vector) index) (- index (count vector))
- (number? index) index))
- ([map x y]
- (list (adjust-index map x) (adjust-index (nth map x) y))))
- (def a '((1 2) (3 4)))
- (adjust-index a 1 -1) ;; (1 1)
- (adjust-index a -1 1) ;; java.lang.IndexOutOfBoundsException||
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement