aboutsummaryrefslogtreecommitdiff
path: root/src/clojure
diff options
context:
space:
mode:
authorStuart Sierra <mail@stuartsierra.com>2008-12-23 15:00:31 +0000
committerStuart Sierra <mail@stuartsierra.com>2008-12-23 15:00:31 +0000
commit597c8abc97cd1a059b03c49a999db7908a5011a2 (patch)
tree5bbda1592777396ed24fe2b8486907e6b386700d /src/clojure
parent9d0caa80410b8794327e587611f85955da55c087 (diff)
condp.clj renamed to condt.clj (t for template) since clojure.core has its own condp now
Diffstat (limited to 'src/clojure')
-rw-r--r--src/clojure/contrib/condt.clj (renamed from src/clojure/contrib/condp.clj)26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/clojure/contrib/condp.clj b/src/clojure/contrib/condt.clj
index 4f7c0dd2..f4019ba8 100644
--- a/src/clojure/contrib/condp.clj
+++ b/src/clojure/contrib/condt.clj
@@ -1,7 +1,7 @@
-;;; condp.clj - generic case-like macro using template expressions
+;;; condt.clj - generic case-like macro using template expressions
;; By Stuart Sierra, http://stuartsierra.com/
-;; December 15, 2008
+;; December 23, 2008
;; Copyright (c) Stuart Sierra, 2008. All rights reserved. The use
;; and distribution terms for this software are covered by the Eclipse
@@ -12,13 +12,21 @@
;; remove this notice, or any other, from this software.
-(ns clojure.contrib.condp
+;; CHANGE LOG
+;;
+;; December 23, 2008: renamed to condt, since clojure.core now
+;; contains a (different) condp as of Clojure SVN rev. 1180
+;;
+;; December 15, 2008: original version, named "condp"
+
+
+(ns clojure.contrib.condt
(:require clojure.contrib.template))
-(defmacro condp
+(defmacro condt
"expr is a template expression (see template), clauses are test/expr
pairs like cond. Evalautes the template on each test value, one at
- a time. If a test returns logical true, condp evaluates the
+ a time. If a test returns logical true, condt evaluates the
corresponding expr and returns its value. If none of the tests are
true, and there are an odd number of clauses, the last clause is
evaluated, otherwise returns nil."
@@ -34,14 +42,14 @@
`(let [~test-fn-sym (clojure.contrib.template/template ~expr)]
~(f clauses))))
-(defmacro econdp
- "Like condp but throws Exception if no tests match."
+(defmacro econdt
+ "Like condt but throws Exception if no tests match."
[expr & clauses]
(let [test-fn-sym (gensym "test_")
f (fn this [c]
(cond
- (empty? c) '(throw (Exception. "Nothing matched in econdp."))
- (= 1 (count c)) (throw (IllegalStateException. "Odd number of clauses in econdp."))
+ (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 (rrest c)))))]