From: David Vázquez Date: Mon, 6 May 2013 13:14:18 +0000 (+0100) Subject: Move more code to sequence.lisp X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=10335c06c6bbffbad74e9a4aa218fba923d1f6f4;p=jscl.git Move more code to sequence.lisp --- diff --git a/src/boot.lisp b/src/boot.lisp index 9e9b027..72c43cb 100644 --- a/src/boot.lisp +++ b/src/boot.lisp @@ -397,30 +397,6 @@ (and (<= 0 weight 9) (char "0123456789" weight))) -(defun subseq (seq a &optional b) - (if b - (slice seq a b) - (slice seq a))) - -(defmacro do-sequence (iteration &body body) - (let ((seq (gensym)) - (index (gensym))) - `(let ((,seq ,(second iteration))) - (cond - ;; Strings - ((stringp ,seq) - (let ((,index 0)) - (dotimes (,index (length ,seq)) - (let ((,(first iteration) - (char ,seq ,index))) - ,@body)))) - ;; Lists - ((listp ,seq) - (dolist (,(first iteration) ,seq) - ,@body)) - (t - (error "type-error!")))))) - (defun equal (x y) (cond ((eql x y) t) diff --git a/src/sequence.lisp b/src/sequence.lisp index e5e7aca..42e7795 100644 --- a/src/sequence.lisp +++ b/src/sequence.lisp @@ -13,6 +13,25 @@ ;; You should have received a copy of the GNU General Public License ;; along with JSCL. If not, see . +(defmacro do-sequence (iteration &body body) + (let ((seq (gensym)) + (index (gensym))) + `(let ((,seq ,(second iteration))) + (cond + ;; Strings + ((stringp ,seq) + (let ((,index 0)) + (dotimes (,index (length ,seq)) + (let ((,(first iteration) + (char ,seq ,index))) + ,@body)))) + ;; Lists + ((listp ,seq) + (dolist (,(first iteration) ,seq) + ,@body)) + (t + (error "type-error!")))))) + (defmacro doseq ((elt seq &optional index) &body body) (let* ((nseq (gensym "seq")) (i (or index (gensym "i"))) @@ -112,3 +131,9 @@ (cons (car list) (remove-if-not func (cdr list)))) (t (remove-if-not func (cdr list))))) + +(defun subseq (seq a &optional b) + (if b + (slice seq a b) + (slice seq a))) +