File tree Expand file tree Collapse file tree 1 file changed +15
-21
lines changed Expand file tree Collapse file tree 1 file changed +15
-21
lines changed Original file line number Diff line number Diff line change 199
199
[pred coll]
200
200
(filter (complement pred) coll))
201
201
202
+ (defcurried flatten
203
+ " Takes any nested combination of sequential things (lists, vectors,
204
+ etc.) and returns their contents as a single, flat foldable
205
+ collection."
206
+ {:added " 1.5" }
207
+ [coll]
208
+ (folder coll
209
+ (fn [f1]
210
+ (fn
211
+ ([] (f1 ))
212
+ ([ret v]
213
+ (if (sequential? v)
214
+ (clojure.core.protocols/coll-reduce (flatten v) f1 ret)
215
+ (f1 ret v)))))))
216
+
202
217
(defcurried take-while
203
218
" Ends the reduction of coll when (pred val) returns logical false."
204
219
{:added " 1.5" }
239
254
(f1 ret k v)
240
255
ret)))))))
241
256
242
- (defcurried flatten
243
- " Takes any nested combination of sequential things (lists, vectors,
244
- etc.) and returns their contents as a single, flat foldable
245
- collection."
246
- {:added " 1.5" }
247
- [coll]
248
- (let [rf (fn [f1]
249
- (fn
250
- ([] (f1 ))
251
- ([ret v]
252
- (if (sequential? v)
253
- (clojure.core.protocols/coll-reduce (flatten v) f1 ret)
254
- (f1 ret v)))))]
255
- (reify
256
- clojure.core.protocols/CollReduce
257
- (coll-reduce [this f1] (clojure.core.protocols/coll-reduce this f1 (f1 )))
258
- (coll-reduce [_ f1 init] (clojure.core.protocols/coll-reduce coll (rf f1) init))
259
-
260
- CollFold
261
- (coll-fold [_ n combinef reducef] (coll-fold coll n combinef (rf reducef))))))
262
-
263
257
; ;do not construct this directly, use cat
264
258
(deftype Cat [cnt left right]
265
259
clojure.lang.Counted
You can’t perform that action at this time.
0 commit comments