         expr
         (future (Thread/sleep millis) (apply f args))))))
 
+(defn safe-subvec [v start end]
+  (let [end (min (count v)
+                 end)]
+    (try
+      (subvec v start end)
+      (catch IndexOutOfBoundsException e []))))
+

  (try
    (if (integer? n)
      n
      (-> n read-string int)) 
    (catch Exception e defval)))

(defn find-with-val [col k v]
  (let [pred 
        (fn [obj]
          (= v (get obj k)))]
    (->> col

       (apply str)))

(defn with-base [base-url & paths]
  (clojure.string/join
    "/" (cons-apply
          (cons base-url paths)
          trim-trailing-slash
          trim-slash)))
