aboutsummaryrefslogtreecommitdiff
path: root/src/main/clojure
diff options
context:
space:
mode:
authorStuart Sierra <mail@stuartsierra.com>2010-01-20 15:39:56 -0500
committerStuart Sierra <mail@stuartsierra.com>2010-01-20 15:39:56 -0500
commit2ede388a9267d175bfaa7781ee9d57532eb4f20f (patch)
treebb42002af196405d7e25cc4e30b4c1c9de5c06d5 /src/main/clojure
parent1bc820d96048a6536706ff999e9892649b53c700 (diff)
Move source files into Maven-style directory structure.
Diffstat (limited to 'src/main/clojure')
-rw-r--r--src/main/clojure/clojure/contrib/accumulators.clj324
-rw-r--r--src/main/clojure/clojure/contrib/accumulators/examples.clj93
-rw-r--r--src/main/clojure/clojure/contrib/agent_utils.clj35
-rw-r--r--src/main/clojure/clojure/contrib/apply_macro.clj43
-rw-r--r--src/main/clojure/clojure/contrib/base64.clj99
-rw-r--r--src/main/clojure/clojure/contrib/classpath.clj39
-rw-r--r--src/main/clojure/clojure/contrib/combinatorics.clj164
-rw-r--r--src/main/clojure/clojure/contrib/command_line.clj122
-rw-r--r--src/main/clojure/clojure/contrib/complex_numbers.clj293
-rw-r--r--src/main/clojure/clojure/contrib/cond.clj34
-rw-r--r--src/main/clojure/clojure/contrib/condition.clj147
-rw-r--r--src/main/clojure/clojure/contrib/condition/Condition.clj43
-rw-r--r--src/main/clojure/clojure/contrib/condition/example.clj66
-rw-r--r--src/main/clojure/clojure/contrib/core.clj81
-rw-r--r--src/main/clojure/clojure/contrib/dataflow.clj508
-rw-r--r--src/main/clojure/clojure/contrib/datalog.clj64
-rw-r--r--src/main/clojure/clojure/contrib/datalog/database.clj287
-rw-r--r--src/main/clojure/clojure/contrib/datalog/example.clj116
-rw-r--r--src/main/clojure/clojure/contrib/datalog/literals.clj414
-rw-r--r--src/main/clojure/clojure/contrib/datalog/magic.clj128
-rw-r--r--src/main/clojure/clojure/contrib/datalog/rules.clj207
-rw-r--r--src/main/clojure/clojure/contrib/datalog/softstrat.clj161
-rw-r--r--src/main/clojure/clojure/contrib/datalog/util.clj89
-rw-r--r--src/main/clojure/clojure/contrib/def.clj147
-rw-r--r--src/main/clojure/clojure/contrib/duck_streams.clj416
-rw-r--r--src/main/clojure/clojure/contrib/error_kit.clj289
-rw-r--r--src/main/clojure/clojure/contrib/except.clj95
-rw-r--r--src/main/clojure/clojure/contrib/fcase.clj108
-rw-r--r--src/main/clojure/clojure/contrib/find_namespaces.clj136
-rw-r--r--src/main/clojure/clojure/contrib/fnmap.clj36
-rw-r--r--src/main/clojure/clojure/contrib/fnmap/PersistentFnMap.clj70
-rw-r--r--src/main/clojure/clojure/contrib/gen_html_docs.clj539
-rw-r--r--src/main/clojure/clojure/contrib/generic.clj54
-rw-r--r--src/main/clojure/clojure/contrib/generic/arithmetic.clj201
-rw-r--r--src/main/clojure/clojure/contrib/generic/collection.clj116
-rw-r--r--src/main/clojure/clojure/contrib/generic/comparison.clj177
-rw-r--r--src/main/clojure/clojure/contrib/generic/functor.clj40
-rw-r--r--src/main/clojure/clojure/contrib/generic/math_functions.clj114
-rw-r--r--src/main/clojure/clojure/contrib/graph.clj228
-rw-r--r--src/main/clojure/clojure/contrib/greatest_least.clj65
-rw-r--r--src/main/clojure/clojure/contrib/http/agent.clj379
-rw-r--r--src/main/clojure/clojure/contrib/http/connection.clj59
-rw-r--r--src/main/clojure/clojure/contrib/import_static.clj63
-rw-r--r--src/main/clojure/clojure/contrib/jar.clj35
-rw-r--r--src/main/clojure/clojure/contrib/java_utils.clj223
-rw-r--r--src/main/clojure/clojure/contrib/javadoc.clj3
-rw-r--r--src/main/clojure/clojure/contrib/javadoc/browse.clj50
-rw-r--r--src/main/clojure/clojure/contrib/javadoc/browse_ui.clj30
-rw-r--r--src/main/clojure/clojure/contrib/jmx.clj121
-rw-r--r--src/main/clojure/clojure/contrib/jmx/Bean.clj35
-rw-r--r--src/main/clojure/clojure/contrib/jmx/client.clj95
-rw-r--r--src/main/clojure/clojure/contrib/jmx/data.clj104
-rw-r--r--src/main/clojure/clojure/contrib/jmx/server.clj18
-rw-r--r--src/main/clojure/clojure/contrib/json/read.clj338
-rw-r--r--src/main/clojure/clojure/contrib/json/write.clj193
-rw-r--r--src/main/clojure/clojure/contrib/lazy_seqs.clj86
-rw-r--r--src/main/clojure/clojure/contrib/lazy_xml.clj189
-rw-r--r--src/main/clojure/clojure/contrib/lazy_xml/with_pull.clj58
-rw-r--r--src/main/clojure/clojure/contrib/load_all.clj91
-rw-r--r--src/main/clojure/clojure/contrib/logging.clj349
-rw-r--r--src/main/clojure/clojure/contrib/macro_utils.clj270
-rw-r--r--src/main/clojure/clojure/contrib/macros.clj84
-rw-r--r--src/main/clojure/clojure/contrib/map_utils.clj55
-rw-r--r--src/main/clojure/clojure/contrib/math.clj247
-rw-r--r--src/main/clojure/clojure/contrib/miglayout.clj79
-rw-r--r--src/main/clojure/clojure/contrib/miglayout/example.clj60
-rw-r--r--src/main/clojure/clojure/contrib/miglayout/internal.clj120
-rw-r--r--src/main/clojure/clojure/contrib/mmap.clj90
-rw-r--r--src/main/clojure/clojure/contrib/mock.clj285
-rw-r--r--src/main/clojure/clojure/contrib/mock/test_adapter.clj38
-rw-r--r--src/main/clojure/clojure/contrib/monadic_io_streams.clj145
-rw-r--r--src/main/clojure/clojure/contrib/monads.clj580
-rw-r--r--src/main/clojure/clojure/contrib/monads/examples.clj425
-rw-r--r--src/main/clojure/clojure/contrib/ns_utils.clj106
-rw-r--r--src/main/clojure/clojure/contrib/pprint.clj35
-rw-r--r--src/main/clojure/clojure/contrib/pprint/ColumnWriter.clj89
-rw-r--r--src/main/clojure/clojure/contrib/pprint/PrettyWriter.clj486
-rw-r--r--src/main/clojure/clojure/contrib/pprint/cl_format.clj1843
-rw-r--r--src/main/clojure/clojure/contrib/pprint/dispatch.clj447
-rw-r--r--src/main/clojure/clojure/contrib/pprint/examples/hexdump.clj63
-rw-r--r--src/main/clojure/clojure/contrib/pprint/examples/json.clj142
-rw-r--r--src/main/clojure/clojure/contrib/pprint/examples/multiply.clj23
-rw-r--r--src/main/clojure/clojure/contrib/pprint/examples/props.clj25
-rw-r--r--src/main/clojure/clojure/contrib/pprint/examples/show_doc.clj50
-rw-r--r--src/main/clojure/clojure/contrib/pprint/examples/xml.clj117
-rw-r--r--src/main/clojure/clojure/contrib/pprint/pprint_base.clj342
-rw-r--r--src/main/clojure/clojure/contrib/pprint/utilities.clj104
-rw-r--r--src/main/clojure/clojure/contrib/probabilities/examples_finite_distributions.clj209
-rw-r--r--src/main/clojure/clojure/contrib/probabilities/examples_monte_carlo.clj73
-rw-r--r--src/main/clojure/clojure/contrib/probabilities/finite_distributions.clj203
-rw-r--r--src/main/clojure/clojure/contrib/probabilities/monte_carlo.clj240
-rw-r--r--src/main/clojure/clojure/contrib/probabilities/random_numbers.clj63
-rw-r--r--src/main/clojure/clojure/contrib/profile.clj110
-rwxr-xr-xsrc/main/clojure/clojure/contrib/prxml.clj166
-rw-r--r--src/main/clojure/clojure/contrib/repl_ln.clj274
-rw-r--r--src/main/clojure/clojure/contrib/repl_utils.clj195
-rw-r--r--src/main/clojure/clojure/contrib/repl_utils/javadoc.clj83
-rw-r--r--src/main/clojure/clojure/contrib/seq_utils.clj223
-rw-r--r--src/main/clojure/clojure/contrib/server_socket.clj94
-rw-r--r--src/main/clojure/clojure/contrib/set.clj47
-rw-r--r--src/main/clojure/clojure/contrib/shell_out.clj146
-rw-r--r--src/main/clojure/clojure/contrib/singleton.clj54
-rw-r--r--src/main/clojure/clojure/contrib/sql.clj203
-rw-r--r--src/main/clojure/clojure/contrib/sql/internal.clj194
-rw-r--r--src/main/clojure/clojure/contrib/str_utils.clj100
-rw-r--r--src/main/clojure/clojure/contrib/str_utils2.clj373
-rw-r--r--src/main/clojure/clojure/contrib/stream_utils.clj276
-rw-r--r--src/main/clojure/clojure/contrib/stream_utils/examples.clj117
-rw-r--r--src/main/clojure/clojure/contrib/swing_utils.clj152
-rw-r--r--src/main/clojure/clojure/contrib/test_is.clj118
-rw-r--r--src/main/clojure/clojure/contrib/trace.clj98
-rw-r--r--src/main/clojure/clojure/contrib/types.clj275
-rw-r--r--src/main/clojure/clojure/contrib/types/examples.clj152
-rw-r--r--src/main/clojure/clojure/contrib/with_ns.clj38
-rw-r--r--src/main/clojure/clojure/contrib/zip_filter.clj92
-rw-r--r--src/main/clojure/clojure/contrib/zip_filter/xml.clj170
116 files changed, 19795 insertions, 0 deletions
diff --git a/src/main/clojure/clojure/contrib/accumulators.clj b/src/main/clojure/clojure/contrib/accumulators.clj
new file mode 100644
index 00000000..dcd03dd1
--- /dev/null
+++ b/src/main/clojure/clojure/contrib/accumulators.clj
@@ -0,0 +1,324 @@
+;; Accumulators
+
+;; by Konrad Hinsen
+;; last updated May 19, 2009
+
+;; This module defines various accumulators (list, vector, map,
+;; sum, product, counter, and combinations thereof) with a common
+;; interface defined by the multimethods add and combine.
+;; For each accumulator type, its empty value is defined in this module.
+;; Applications typically use this as a starting value and add data
+;; using the add multimethod.
+
+;; Copyright (c) Konrad Hinsen, 2009. All rights reserved. The use
+;; and distribution terms for this software are covered by the Eclipse
+;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
+;; 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.
+
+(ns
+ #^{:author "Konrad Hinsen"
+ :doc "A generic accumulator interface and implementations of various
+ accumulators."}
+ clojure.contrib.accumulators
+ (:refer-clojure :exclude (deftype))
+ (:use [clojure.contrib.types :only (deftype)])
+ (:use [clojure.contrib.def :only (defvar defvar- defmacro-)])
+ (:require [clojure.contrib.generic.arithmetic :as ga]))
+
+(defmulti add
+ "Add item to the accumulator acc. The exact meaning of adding an
+ an item depends on the type of the accumulator."
+ {:arglists '([acc item])}
+ (fn [acc item] (type acc)))
+
+(defn add-items
+ "Add all elements of a collection coll to the accumulator acc."
+ [acc items]
+ (reduce add acc items))
+
+(defmulti combine
+ "Combine the values of the accumulators acc1 and acc2 into a
+ single accumulator of the same type."
+ {:arglists '([& accs])}
+ (fn [& accs] (type (first accs))))
+
+;
+; An ::accumulator type tag is attached to tbe built-in types
+; when used as accumulators, and new types are derived from it.
+; Multimethods add and combine for ::accumulator sub-dispatch on class.
+; We also define generic addition as the combine operation.
+;
+(let [meta-map {:type ::accumulator}]
+ (defn- with-acc-tag
+ [x]
+ (with-meta x meta-map)))
+
+(defmethod add ::accumulator
+ [a e]
+ ((get-method add (class a)) a e))
+
+(defmethod combine ::accumulator
+ [& as]
+ (apply (get-method combine (class (first as))) as))
+
+(defmethod ga/+ ::accumulator
+ [x y]
+ (combine x y))
+
+;
+; Vector accumulator
+;
+(defvar empty-vector (with-acc-tag [])
+ "An empty vector accumulator. Adding an item appends it at the end.")
+
+(defmethod combine clojure.lang.IPersistent