File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88 SEXP strings.
99- Reducer: ` quantities ` for counting unique occurrences of streamed items.
1010- Reducer: ` partition ` for splitting the stream results.
11+ - Reducer: ` base-string ` for reducing into a ` simple-base-string ` .
1112
1213#### Changed
1314
14- - The ` vector ` , ` string ` , and ` average ` reducers are now faster and use less memory.
15+ - Reducer: ` vector ` and ` average ` are now faster and use less memory.
16+ - Reducer: ` string ` is now more efficient and yields the specialized
17+ ` (simple-array character (*)) ` type.
1518- ` comp ` is now a macro and uses less memory for long composition chains.
1619
1720#### Fixed
Original file line number Diff line number Diff line change 11(defpackage transducers
22 (:use :cl )
33 (:shadow # :map # :concatenate # :log # :step # :split
4- # :cons # :count # :first # :last # :max # :min # :find # :string # :vector # :hash-table
4+ # :string # :base-string # :vector # :hash-table
5+ # :cons # :count # :first # :last # :max # :min # :find
56 # :random)
67 ; ; --- Entry Points --- ;;
78 (:export # :transduce)
Original file line number Diff line number Diff line change @@ -16,15 +16,27 @@ reversal."
1616 ((and a? (not i?)) acc)
1717 (t ' ())))
1818
19- (declaim (ftype (function (&optional (or cl :string null ) character ) cl :string) string ))
2019(defun string (&optional (acc nil a?) (input #\z i?))
21- " Reducer: Collect a stream of characters into to a single string."
22- (cond ((and a? i?) (vector-push-extend input acc) acc)
23- ((and a? (not i?)) acc)
24- (t (make-array 16 :element-type ' character :adjustable t :fill-pointer 0 ))))
20+ " Reducer: Collect a stream of characters into to a `simple-string'."
21+ (cond ((and a? i?)
22+ (write-char input acc)
23+ acc)
24+ ((and a? (not i?)) (get-output-stream-string acc))
25+ (t (make-string-output-stream :element-type ' character))))
26+
27+ #+ nil
28+ (transduce (map #' char-upcase ) #' string " hello" )
29+
30+ (defun base-string (&optional (acc nil a?) (input #\z i?))
31+ " Reducer: Collect a stream of characters into to a single string of `base-char'."
32+ (cond ((and a? i?)
33+ (write-char input acc)
34+ acc)
35+ ((and a? (not i?)) (get-output-stream-string acc))
36+ (t (make-string-output-stream :element-type ' base-char))))
2537
2638#+ nil
27- (string- transduce (map #' char-upcase ) #' string " hello" )
39+ (transduce (map #' char-upcase ) #' base- string " hello" )
2840
2941(declaim (ftype (function (&optional (or cl :vector null ) t ) cl :vector) vector ))
3042(defun vector (&optional (acc nil a?) (input nil i?))
You can’t perform that action at this time.
0 commit comments