Ignore:
Timestamp:
03/03/10 21:05:41 (11 years ago)
Author:
astalla
Message:

Support for user-extensible sequences, adapted from SBCL.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/reduce.lisp

    r11391 r12516  
    3434(in-package #:system)
    3535
     36(require "EXTENSIBLE-SEQUENCES-BASE")
     37
    3638(defmacro list-reduce (function sequence start end initial-value ivp key)
    3739  (let ((what `(if ,key (funcall ,key (car sequence)) (car sequence))))
     
    5759
    5860
    59 (defun reduce (function sequence &key from-end (start 0)
     61(defun reduce (function sequence &rest args &key from-end (start 0)
    6062                        end (initial-value nil ivp) key)
    6163  (unless end (setq end (length sequence)))
    6264  (if (= end start)
    6365      (if ivp initial-value (funcall function))
    64       (if (listp sequence)
     66      (sequence::seq-dispatch sequence
    6567          (if from-end
    6668              (list-reduce-from-end function sequence start end initial-value ivp key)
     
    8183                    value (funcall function
    8284                                   (if from-end element value)
    83                                    (if from-end value element))))))))
     85                                   (if from-end value element)))))
     86    (apply #'sequence:reduce function sequence args))))
Note: See TracChangeset for help on using the changeset viewer.