aboutsummaryrefslogtreecommitdiff
path: root/src/clojure/contrib/expect/util.clj
blob: 14bd6d165f058758031dff1cbb353d269ac1e88b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
(ns clojure.contrib.expect.util
  (:use clojure.contrib.seq-utils))

(defmacro assert-args [fnname & pairs]
  `(do (when-not ~(first pairs)
         (throw (IllegalArgumentException.
                  ~(str fnname " requires " (second pairs)))))
     ~(let [more (nnext pairs)]
        (when more
          (list* `assert-args fnname more)))))

(defn index-of
  "Returns the first index of value v in the collection or nil."
  [coll v]
  (first (positions v coll)))