econdt(clojure.contrib.condt)

Macro

Like condt but throws Exception if no tests match.

; clojure/contrib/condt.clj:50
(defmacro econdt
  [expr & clauses]
  (let [test-fn-sym (gensym "test_")
        f (fn this [c]
              (cond
               (empty? c) '(throw (Exception. "Nothing matched in econdt."))
               (= 1 (count c)) (throw (IllegalStateException. "Odd number of clauses in econdt."))
               :else (list 'if (list test-fn-sym (first c))
                           (second c)
                           (this (nthnext c 2)))))]
    `(let [~test-fn-sym (clojure.contrib.template/template ~expr)]
       ~(f clauses))))

Copyright (c) Rich Hickey. All rights reserved.

The use and distribution terms for this software are covered by the Eclipse Public License 1.0, which can be found in the file epl-v10.html at the root of this distribution. By using this software in any fashion, you are agreeing to be bound by the terms of this license. You must not remove this notice, or any other, from this software.