Skip to content

Commit

Permalink
Use boolean-if in list-runs
Browse files Browse the repository at this point in the history
  • Loading branch information
ruricolist committed Oct 17, 2023
1 parent 269fddd commit f005858
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions sequences.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -650,28 +650,30 @@ instead. However TEST must be acceptable as the `:test' argument to
(cdr list))
(let ((x (caar runs)))
(if (test x y)
(rec (cons (if compare-last
(cons y (car runs))
(list* x y (cdar runs)))
(cdr runs))
(rec (cons
(boolean-if compare-last
(cons y (car runs))
(list* x y (cdar runs)))
(cdr runs))
count
(rest list))
(if (zerop (1- count))
runs
(rec (list* (list y)
(if compare-last
(nreverse (car runs))
(cons (caar runs)
(nreverse (cdar runs))))
(cdr runs))
(rec (list*
(list y)
(boolean-if compare-last
(nreverse (car runs))
(cons (caar runs)
(nreverse (cdar runs))))
(cdr runs))
(1- count)
(rest list)))))))))))
(nreverse
(if compare-last
(cons (nreverse (car runs)) (cdr runs))
(cons (cons (caar runs)
(nreverse (cdar runs)))
(cdr runs))))))))
(boolean-if compare-last
(cons (nreverse (car runs)) (cdr runs))
(cons (cons (caar runs)
(nreverse (cdar runs)))
(cdr runs))))))))

(defun runs (seq &key (start 0) end (key #'identity) (test #'eql) compare-last
(count most-positive-fixnum))
Expand Down

0 comments on commit f005858

Please sign in to comment.