@@ -72,10 +72,9 @@ keep results that are non-nil.
7272 (lambda (reducer)
7373 (let ((drop? t ))
7474 (lambda (result &optional (input nil i?))
75- (if i? (if (and drop? (funcall pred input))
76- result
77- (progn (setf drop? nil )
78- (funcall reducer result input)))
75+ (if i? (cond ((and drop? (funcall pred input)) result)
76+ (t (setf drop? nil )
77+ (funcall reducer result input)))
7978 (funcall reducer result))))))
8079
8180#+ nil
@@ -138,10 +137,10 @@ transduction as soon as any element fails the test."
138137 " Transducer: Concatenate all the sublists and subvectors in the transduction."
139138 (let ((preserving-reducer (preserving-reduced reducer)))
140139 (lambda (result &optional (input nil i?))
141- (if i? (etypecase input
140+ (if i? (typecase input
142141 (cl :list (list-reduce preserving-reducer result input))
143142 (cl :vector (vector-reduce preserving-reducer result input))
144- (t (error ' unusable-type :type (type-of input))))
143+ (otherwise (error ' unusable-type :type (type-of input))))
145144 (funcall reducer result)))))
146145
147146#+ nil
@@ -159,10 +158,10 @@ transduction as soon as any element fails the test."
159158 " Transducer: Entirely flatten all lists and vectors in the transduction,
160159regardless of nesting."
161160 (lambda (result &optional (input nil i?))
162- (if i? (etypecase input
161+ (if i? (typecase input
163162 (cl :list (list-reduce (preserving-reduced (flatten reducer)) result input))
164163 (cl :vector (vector-reduce (preserving-reduced (flatten reducer)) result input))
165- (t (funcall reducer result input)))
164+ (otherwise (funcall reducer result input)))
166165 (funcall reducer result))))
167166
168167#+ nil
@@ -223,14 +222,14 @@ transduction.
223222 (collect ' ()))
224223 (lambda (result &optional (input nil i?))
225224 (if i? (let ((fout (funcall f input)))
226- (if (or (equal fout prev) (eq prev ' nothing))
227- ( progn (setf prev fout)
228- (setf collect (cl :cons input collect))
229- result)
230- (let ((next-input (reverse collect)))
231- (setf prev fout)
232- (setf collect (list input))
233- (funcall reducer result next-input))))
225+ (cond ( (or (equal fout prev) (eq prev ' nothing))
226+ (setf prev fout)
227+ (setf collect (cl :cons input collect))
228+ result)
229+ ( t (let ((next-input (reverse collect)))
230+ (setf prev fout)
231+ (setf collect (list input))
232+ (funcall reducer result next-input) ))))
234233 (let ((result (if (null collect)
235234 result
236235 (funcall reducer result (reverse collect)))))
@@ -247,13 +246,12 @@ transduction.
247246 (lambda (reducer)
248247 (let ((send-elem? nil ))
249248 (lambda (result &optional (input nil i?))
250- (if i? (if send-elem?
251- (let ((result (funcall reducer result elem)))
252- (if (reduced? result)
253- result
254- (funcall reducer result input)))
255- (progn (setf send-elem? t )
256- (funcall reducer result input)))
249+ (if i? (cond (send-elem? (let ((result (funcall reducer result elem)))
250+ (if (reduced? result)
251+ result
252+ (funcall reducer result input))))
253+ (t (setf send-elem? t )
254+ (funcall reducer result input)))
257255 (funcall reducer result))))))
258256
259257#+ nil
@@ -341,10 +339,9 @@ not careful."
341339 (let ((seen (make-hash-table :test #' equal )))
342340 (lambda (result &optional (input nil i?))
343341 (if i? (let ((mapped (funcall f input)))
344- (if (gethash mapped seen)
345- result
346- (progn (setf (gethash mapped seen) t )
347- (funcall reducer result input))))
342+ (cond ((gethash mapped seen) result)
343+ (t (setf (gethash mapped seen) t )
344+ (funcall reducer result input))))
348345 (funcall reducer result))))))
349346
350347#+ +
@@ -356,10 +353,9 @@ not careful."
356353 " Transducer: Remove adjacent duplicates from the transduction."
357354 (let ((prev ' nothing))
358355 (lambda (result &optional (input nil i?))
359- (if i? (if (equal prev input)
360- result
361- (progn (setf prev input)
362- (funcall reducer result input)))
356+ (if i? (cond ((equal prev input) result)
357+ (t (setf prev input)
358+ (funcall reducer result input)))
363359 (funcall reducer result)))))
364360
365361#+ nil
@@ -388,11 +384,11 @@ of the transduction is always included.
388384 (lambda (reducer)
389385 (let ((curr 1 ))
390386 (lambda (result &optional (input nil i?))
391- (if i? (if (= 1 curr)
392- ( progn (setf curr n)
393- (funcall reducer result input))
394- ( progn (setf curr (1- curr))
395- result))
387+ (if i? (cond ( (= 1 curr)
388+ (setf curr n)
389+ (funcall reducer result input))
390+ ( t (setf curr (1- curr))
391+ result))
396392 (funcall reducer result)))))))
397393
398394#+ nil
@@ -430,10 +426,9 @@ applications of a given function F.
430426 (lambda (result &optional (input nil i?))
431427 (cond ((and i? unused?)
432428 (let ((res (funcall reducer result item)))
433- (if (reduced? res)
434- res
435- (progn (setf unused? nil )
436- (funcall reducer res input)))))
429+ (cond ((reduced? res) res)
430+ (t (setf unused? nil )
431+ (funcall reducer res input)))))
437432 (i? (funcall reducer result input))
438433 ; ; A weird case where they specified `once', but the original
439434 ; ; Source itself was empty.
@@ -479,9 +474,9 @@ occur when transducing over a stream/file line-by-line."
479474 (funcall reducer res curr)))
480475 ((< parens 0 ) (error ' unmatched-closing-paren))
481476 (t res)))
482- (t (cond ((zerop parens) res)
483- (t (write-char c acc)
484- res)))))
477+ (otherwise (cond ((zerop parens) res)
478+ (t (write-char c acc)
479+ res)))))
485480 (a-string (res i)
486481 (declare (type fixnum i))
487482 (cond ((= i (length input)) res)
@@ -519,9 +514,9 @@ need for the caller to manually pass a REDUCER."
519514 (let ((headers nil ))
520515 (lambda (result &optional (input nil i?))
521516 (if i? (let ((items (split-csv-line input)))
522- (if headers (funcall reducer result (zipmap headers items))
523- ( progn (setf headers items)
524- result)))
517+ (cond ( headers (funcall reducer result (zipmap headers items) ))
518+ ( t (setf headers items)
519+ result)))
525520 (funcall reducer result)))))
526521
527522#+ nil
@@ -578,10 +573,9 @@ table whose keys are strings that match the values found in HEADERS.
578573 (lambda (result &optional (input nil i?))
579574 (if i? (if unsent
580575 (let ((res (funcall reducer result (recsv headers))))
581- (if (reduced? res)
582- res
583- (progn (setf unsent nil )
584- (funcall reducer res (table-vals->csv headers input)))))
576+ (cond ((reduced? res) res)
577+ (t (setf unsent nil )
578+ (funcall reducer res (table-vals->csv headers input)))))
585579 (funcall reducer result (table-vals->csv headers input)))
586580 (funcall reducer result)))))))
587581
0 commit comments