 	   (next vs)))
       (make-interval l lo r ro))))
 
+(defn scale-interval [i c]
+  (let [l (:left i) r (:right i)]
+    (if (>= c 0) (assoc i :left (* c l) :right (* c r))
+	(make-interval (* r c) (:right-open i) (* l c) (:left-open i)))))
+   
+(defn abs-interval [i]
+  (if (>= (:left i) 0) i
+      (let [l (abs (:left i)) lo (:left-open i) r (:right i) ro (:right-open i)]
+	(cond (= l r) 
+	        (make-interval 0 false l (and lo ro))
+	      (> l r) 
+	        (make-interval 0 false l lo)
+	      (< l r) 
+	        (make-interval 0 false r ro)))))
+
 (defn bisect-interval [i]
   (assert-is (not (interval-point interval)))
   (let [{:keys [left right left-open right-open]} i

		 (- (:right i1) (:left i2))
		 (or (:right-open i1) (:left-open i2))))

(defn multiply-intervals [i1 i2]
  (loop [l (+ 0 Double/POSITIVE_INFINITY) lo false r (+ 0 Double/NEGATIVE_INFINITY) ro false 
	 vs     (seq (for [[e1 o1] [[(:left i1) (:left-open i1)] [(:right i1) (:right-open i1)]]

(defn intersect-intervals [i1 i2]
  (let [l1 (:left i1) r1 (:right i1) lo1 (:left-open i1) ro1 (:right-open i1)
	l2 (:left i2) r2 (:right i2) lo2 (:left-open i2) ro2 (:right-open i2)]
    (make-interval 
	    (max l1 l2)
	    (cond (> l1 l2) lo1 (< l1 l2) lo2 :else (or lo1 lo2))
	    (min r1 r2)
