diff --git a/src/lsp/seq.lsp b/src/lsp/seq.lsp index ccbb70b21..f20398a80 100644 --- a/src/lsp/seq.lsp +++ b/src/lsp/seq.lsp @@ -261,24 +261,23 @@ SEQUENCEs." Creates and returns a sequence of TYPE with K elements, with the N-th element being the value of applying FUNCTION to the N-th elements of the given SEQUENCEs, where K is the minimum length of the given SEQUENCEs." - (setq more-sequences (cons sequence more-sequences)) - (do* ((l (apply #'min (mapcar #'length more-sequences))) - (it (mapcar #'make-seq-iterator more-sequences)) - (val (make-sequence 'list (length more-sequences))) - (x (unless (null result-type) (make-sequence result-type l))) - (ix (unless (null result-type) (make-seq-iterator x)))) - (nil) - (do ((i it (cdr i)) - (v val (cdr v)) - (s more-sequences (cdr s))) - ((null i)) - (unless (car i) (return-from map x)) - (rplaca v (seq-iterator-ref (car s) (car i))) - (rplaca i (seq-iterator-next (car s) (car i)))) - (let ((that-value (apply function val))) - (unless (null result-type) - (seq-iterator-set x ix that-value) - (setq ix (seq-iterator-next x ix)))))) + (let* ((sequences (list* sequence more-sequences)) + (function (si::coerce-to-function function)) + output + it) + (when result-type + (let ((l (length sequence))) + (when more-sequences + (setf l (l (reduce #'min more-sequences + :initial-value l + :key #'length)))) + (setf output (make-sequence result-type l) + it (make-seq-iterator output)))) + (do-sequences (elt-list sequences :output output) + (let ((value (apply function elt-list))) + (when result-type + (seq-iterator-set output it value) + (setf it (seq-iterator-next output it))))))) (defun some (predicate sequence &rest more-sequences) "Args: (predicate sequence &rest more-sequences) @@ -292,9 +291,10 @@ NIL otherwise." (defun every (predicate sequence &rest more-sequences) "Args: (predicate sequence &rest more-sequences) Returns T if every elements of SEQUENCEs satisfy PREDICATE; NIL otherwise." - (do-sequences (elt-list (cons sequence more-sequences) :output t) - (unless (apply predicate elt-list) - (return nil)))) + (reckless + (do-sequences (elt-list (cons sequence more-sequences) :output t) + (unless (apply predicate elt-list) + (return nil))))) #| (def-seq-bool-parser notany