diff options
author | Rich Hickey <richhickey@gmail.com> | 2008-01-14 20:42:11 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2008-01-14 20:42:11 +0000 |
commit | 3f3b97da35f1bdfbae339ea810ee1b13d49ef4e6 (patch) | |
tree | 92400f77f241348161a0549a0909650d6feffc73 | |
parent | ade72b976317c723e60076aead6e1af7e571e06e (diff) |
renamed struct to struct-map, construct to struct. Added to-set and distinct
-rw-r--r-- | clojure.iml | 3 | ||||
-rw-r--r-- | src/boot.clj | 21 |
2 files changed, 18 insertions, 6 deletions
diff --git a/clojure.iml b/clojure.iml index 71c2e404..ce7869b6 100644 --- a/clojure.iml +++ b/clojure.iml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<module version="4" relativePaths="true" type="JAVA_MODULE"> +<module relativePaths="true" type="JAVA_MODULE" version="4"> <component name="BuildJarSettings"> <containerInfo> <containerElement type="module" name="clojure"> @@ -11,7 +11,6 @@ <setting name="buildJar" value="true" /> <setting name="mainClass" value="clojure.lang.Compiler" /> </component> - <component name="ModuleRootManager" /> <component name="NewModuleRootManager" inherit-compiler-output="false"> <output url="file://$MODULE_DIR$/classes" /> <exclude-output /> diff --git a/src/boot.clj b/src/boot.clj index 76af5010..9f4b89e7 100644 --- a/src/boot.clj +++ b/src/boot.clj @@ -953,10 +953,10 @@ (defmacro defstruct [name & keys] `(def ~name (create-struct ~@keys))) -(defn struct [s & inits] +(defn struct-map [s & inits] (. clojure.lang.PersistentStructMap (create s inits))) -(defn construct [s & vals] +(defn struct [s & vals] (. clojure.lang.PersistentStructMap (construct s vals))) (defn accessor [s key] @@ -980,9 +980,21 @@ row-values (fn [] (map (fn [#^Integer i] (. rs (getObject i))) idxs)) rows (fn [] (when (. rs (next)) - (fnseq (apply construct row-struct (row-values)) thisfn)))] + (fnseq (apply struct row-struct (row-values)) thisfn)))] (rows))) +(defn to-set [coll] + (loop [ret {} keys (seq coll)] + (if keys + (recur (if (contains? ret (first keys)) + ret + (assoc ret (first keys) true)) + (rest keys)) + ret))) + +(defn distinct [coll] + (keys (to-set coll))) + (def *exports* '(clojure load-file load @@ -1027,10 +1039,11 @@ max min bit-shift-left bit-shift-right bit-and bit-or bit-xor bit-not - defstruct struct accessor create-struct construct + defstruct struct accessor create-struct struct-map subvec false? true? *warn-on-reflection* resultset-seq + to-set distinct )) |