File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 339339 ([state] (finish- hash - state state))
340340 ([state itm] (update- hash - unordered! state itm))))
341341
342+ (def string- builder
343+ (fn ^ {:doc " Creates a reducing function that builds a string based on calling str on the transduced collection" }
344+ ([] (- string- builder))
345+ ([sb] (str sb))
346+ ([sb item] (conj! sb item))))
342347
343348(extend - str PersistentVector
344349 (fn [v]
@@ -1303,7 +1308,8 @@ and implements IAssociative, ILookup and IObject."
13031308 `(= (~ field self ) (~ field other)))
13041309 fields)))
13051310 `(- hash [self ]
1306- (hash [~ @field- syms]))]
1311+ (hash [~ @field- syms]))
1312+ `IRecord]
13071313 deftype- decl `(deftype ~ nm ~ fields ~ @default- bodies ~ @body)]
13081314 `(do ~ type - from - map
13091315 ~ deftype- decl)))
@@ -2362,6 +2368,13 @@ Expands to calls to `extend-type`."
23622368 [x]
23632369 (- int x))
23642370
2371+ (defprotocol IRecord)
2372+
2373+ (defn record?
2374+ {:doc " Returns true if x implements IRecord"
2375+ :since " 0.1" }
2376+ [x]
2377+ (satisfies? IRecord x))
23652378
23662379(defmacro for
23672380 {:doc " A list comprehension for the bindings."
@@ -2418,12 +2431,6 @@ Expands to calls to `extend-type`."
24182431 ([result] result)
24192432 ([result _] (inc result)))
24202433
2421- (defn string- builder
2422- " Creates a reducing function that builds a string based on calling str on the transduced collection"
2423- ([] (- string- builder))
2424- ([sb] (str sb))
2425- ([sb item] (conj! sb item)))
2426-
24272434(defn dispose!
24282435 " Finalizes use of the object by cleaning up resources used by the object"
24292436 [x]
Original file line number Diff line number Diff line change 1212(t/ deftest test- satisfies
1313 (foreach [t [t1 t2 t3 t4 t5]]
1414 (t/ assert = t t)
15+ (t/ assert (satisfies? IRecord t))
1516 (t/ assert (satisfies? IAssociative t))
1617 (t/ assert (satisfies? ILookup t))))
1718
19+ (t/ deftest test- record- pred
20+ (t/ assert (record? t1)))
21+
1822(t/ deftest test- eq
1923 (t/ assert = t1 t2)
2024 (t/ assert = t2 t3)
You can’t perform that action at this time.
0 commit comments