Skip to content

Commit

Permalink
concat now accepts an arbitrary number of arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikelevins committed Nov 5, 2011
1 parent 0f827ef commit f3656c0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
12 changes: 10 additions & 2 deletions collections/sequences.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,21 @@
;;; concat
;;; ---------------------------------------------------------------------

(defmethod concat (s0 s1)
(defmethod %concat (s0 s1)
(concatenate (classname-for-sequence s0)
s0 (as (classname-for-sequence s0) s1)))

(defmethod concat ((s0 fset:seq) s1)
(defmethod %concat ((s0 fset:seq) s1)
(fset:concat s0 (as 'fset:seq s1)))

(defun concat (&rest sequences)
(if (null sequences)
nil
(if (null (cdr sequences))
(car sequences)
(reduce #'%concat (cddr sequences) :initial-value (%concat (car sequences)
(cadr sequences))))))

;;; ---------------------------------------------------------------------
;;; contains?
;;; ---------------------------------------------------------------------
Expand Down
10 changes: 5 additions & 5 deletions doc/collections/sequences.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ CHOOSE-ANY (s) => val

CHOOSE-ANY returns a randomly-chosen element of S.

CONCAT (s1 s2) => new-s
generic function
CONCAT (&rest sequences) => new-sequence
function

CONCAT returns a new sequence of the same class as (or a superclass
of) S1, whose elements are the elements of S1 followed by the
elements of S2.
CONCAT returns a new sequence whose elements are the elements of S1
followed by the elements of S2. The type of the result sequence is
the same as the type of the first argument sequence.


CONTAINS? (s1 x &key (test 'eql)) => boolean
Expand Down

0 comments on commit f3656c0

Please sign in to comment.