Skip to content

Commit 3f3b97d

Browse files
committed
renamed struct to struct-map, construct to struct. Added to-set and distinct
1 parent ade72b9 commit 3f3b97d

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

clojure.iml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<module version="4" relativePaths="true" type="JAVA_MODULE">
2+
<module relativePaths="true" type="JAVA_MODULE" version="4">
33
<component name="BuildJarSettings">
44
<containerInfo>
55
<containerElement type="module" name="clojure">
@@ -11,7 +11,6 @@
1111
<setting name="buildJar" value="true" />
1212
<setting name="mainClass" value="clojure.lang.Compiler" />
1313
</component>
14-
<component name="ModuleRootManager" />
1514
<component name="NewModuleRootManager" inherit-compiler-output="false">
1615
<output url="file://$MODULE_DIR$/classes" />
1716
<exclude-output />

src/boot.clj

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -953,10 +953,10 @@
953953
(defmacro defstruct [name & keys]
954954
`(def ~name (create-struct ~@keys)))
955955

956-
(defn struct [s & inits]
956+
(defn struct-map [s & inits]
957957
(. clojure.lang.PersistentStructMap (create s inits)))
958958

959-
(defn construct [s & vals]
959+
(defn struct [s & vals]
960960
(. clojure.lang.PersistentStructMap (construct s vals)))
961961

962962
(defn accessor [s key]
@@ -980,9 +980,21 @@
980980
row-values (fn [] (map (fn [#^Integer i] (. rs (getObject i))) idxs))
981981
rows (fn []
982982
(when (. rs (next))
983-
(fnseq (apply construct row-struct (row-values)) thisfn)))]
983+
(fnseq (apply struct row-struct (row-values)) thisfn)))]
984984
(rows)))
985985

986+
(defn to-set [coll]
987+
(loop [ret {} keys (seq coll)]
988+
(if keys
989+
(recur (if (contains? ret (first keys))
990+
ret
991+
(assoc ret (first keys) true))
992+
(rest keys))
993+
ret)))
994+
995+
(defn distinct [coll]
996+
(keys (to-set coll)))
997+
986998
(def *exports*
987999
'(clojure
9881000
load-file load
@@ -1027,10 +1039,11 @@
10271039
max min
10281040
bit-shift-left bit-shift-right
10291041
bit-and bit-or bit-xor bit-not
1030-
defstruct struct accessor create-struct construct
1042+
defstruct struct accessor create-struct struct-map
10311043
subvec
10321044
false? true?
10331045
*warn-on-reflection*
10341046
resultset-seq
1047+
to-set distinct
10351048
))
10361049

0 commit comments

Comments
 (0)