 ;; WID requires that a strict lower-bound of the windowing attribute
 ;; be defined. In our example, this will be 0. We will use a window
 ;; range of 20, and a slide value of 5. `extents` tells of which values
-;; of `:window-key` fall into their respect windows via:
+;; of the windowing key fall into their respect windows via:
 ;;
 ;; (doseq [n (range 20)]
 ;;  (println n ": " (extents 0 20 5 n)))

;; up with both tables we looked at above.
;;
;; (doseq [n (range 30)]
;;   (println n "=>" (wids 0 20 5 {:window-key n})))

;; 0 => (0 1 2 3)
;; 1 => (0 1 2 3)

;; `wids` is defined in section 3.4 of the paper. This is the variant
;; of the algorithm that also covers the case where range and slide
;; are defined on the same value.
(defn wids-lower [min-windowing-attr w-slide w-key t]
  (dec (long (Math/floor (/ (- (get t w-key)
                               min-windowing-attr) w-slide)))))

(defn wids-upper [min-windowing-attr w-range w-slide w-key t]
  (dec (long (Math/floor (/ (- (+ (get t w-key) w-range)
                               min-windowing-attr) w-slide)))))

(defn wids [min-windowing-attr w-range w-slide w-key t]
  (let [lower (wids-lower min-windowing-attr w-slide w-key t)
        upper (wids-upper min-windowing-attr w-range w-slide w-key t)]
    (range (inc lower) (inc upper))))

;; The follow code runs through 30 segments with
