From dce795f7f042b1c96d9f3ed47214cb8c2f738c1e Mon Sep 17 00:00:00 2001 From: AJ Rossini Date: Wed, 12 Nov 2008 10:39:26 +0100 Subject: [PATCH] getting rid of sequencep across the codebase. Signed-off-by: AJ Rossini --- src/basics/compound.lsp | 2 +- src/data/matrix.lisp | 26 +++++++++++++------------- src/numerics/optimize.lisp | 2 +- src/packages.lisp | 8 +++++--- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/basics/compound.lsp b/src/basics/compound.lsp index 498b61b..13af04d 100644 --- a/src/basics/compound.lsp +++ b/src/basics/compound.lsp @@ -452,7 +452,7 @@ and it's poorly documented." (k 0)) (declare (fixnum rank n)) - (if (or (sequencep a) + (if (or (typep a 'sequence) (not (arrayp a))) (error "not an array - ~a" a)) (if (not (listp indexlist)) diff --git a/src/data/matrix.lisp b/src/data/matrix.lisp index 74c16de..e37aa70 100644 --- a/src/data/matrix.lisp +++ b/src/data/matrix.lisp @@ -103,13 +103,13 @@ Returns number of columns in X." Returns the matrix product of matrices a, b, etc. If a is a vector it is treated as a row vector; if b is a vector it is treated as a column vector." (let ((rtype (cond ((and (matrixp a) (matrixp b)) 'matrix) - ((and (sequencep a) (sequencep b)) 'number) - ((sequencep a) (if (consp a) 'list 'vector)) - ((sequencep b) (if (consp b) 'list 'vector))))) + ((and (typep a 'sequence) (typep b 'sequence)) 'number) + ((typep a 'sequence) (if (consp a) 'list 'vector)) + ((typep b 'sequence) (if (consp b) 'list 'vector))))) - (if (sequencep a) + (if (typep a 'sequence) (setf a (vector-to-array (coerce a 'vector) (list 1 (length a))))) - (if (sequencep b) + (if (typep b 'sequence) (setf b (vector-to-array (coerce b 'vector) (list (length b) 1)))) (if (not (= (array-dimension a 1) (array-dimension b 0))) (error "dimensions do not match")) @@ -155,7 +155,7 @@ of X." (result (make-array n))) (dotimes (i n (coerce result 'list)) (setf (aref result i) (aref x i i))))) - ((sequencep x) + ((typep x 'sequence) (let* ((x (coerce x 'vector)) (n (length x)) (result (make-array (list n n) :initial-element 0))) @@ -289,10 +289,10 @@ The ARGS can be matrices, vectors, or lists. Arguments are bound into a matrix along their columns. Example: (bind-columns #2a((1 2)(3 4)) #(5 6)) returns #2a((1 2 5)(3 4 6))" (flet ((check-arg (x) - (if (not (or (sequencep x) (matrixp x))) + (if (not (or (typep x 'sequence) (matrixp x))) (error "bad argument type"))) - (arg-cols (x) (if (sequencep x) 1 (num-cols x))) - (arg-rows (x) (if (sequencep x) (length x) (num-rows x)))) + (arg-cols (x) (if (typep x 'sequence) 1 (num-cols x))) + (arg-rows (x) (if (typep x 'sequence) (length x) (num-rows x)))) (dolist (x args) (check-arg x)) (let ((m (arg-rows (first args))) (n (arg-cols (first args)))) @@ -323,10 +323,10 @@ The ARGS can be matrices, vectors, or lists. Arguments are bound into a matrix along their rows. Example: (bind-rows #2a((1 2)(3 4)) #(5 6)) returns #2a((1 2)(3 4)(5 6))" (flet ((check-arg (x) - (if (not (or (sequencep x) (matrixp x))) + (if (not (or (typep x 'sequence) (matrixp x))) (error "bad argument type"))) - (arg-cols (x) (if (sequencep x) (length x) (num-cols x))) - (arg-rows (x) (if (sequencep x) 1 (num-rows x)))) + (arg-cols (x) (if (typep x 'sequence) (length x) (num-cols x))) + (arg-rows (x) (if (typep x 'sequence) 1 (num-rows x)))) (dolist (x args) (check-arg x)) (let ((m (arg-rows (first args))) (n (arg-cols (first args)))) @@ -340,7 +340,7 @@ Example: (bind-rows #2a((1 2)(3 4)) #(5 6)) returns #2a((1 2)(3 4)(5 6))" (x (first args) (first args))) ((null args) result) (cond - ((sequencep x) + ((typep x 'sequence) (let ((cx (make-next-element x))) (dotimes (i n) (setf (aref result firstrow i) (get-next-element cx i))))) diff --git a/src/numerics/optimize.lisp b/src/numerics/optimize.lisp index 539ced3..0705e92 100644 --- a/src/numerics/optimize.lisp +++ b/src/numerics/optimize.lisp @@ -435,7 +435,7 @@ control the behavior of simplex algorithm." (defmeth simplex-proto :simplex (&optional new size) (if new (let ((simplex - (if (and (consp new) (sequencep (car new))) + (if (and (consp new) (typep (car new) 'sequence)) (if (/= (length new) (+ 1 (length (car new)))) (error "bad simplex data") (copy-list new)) diff --git a/src/packages.lisp b/src/packages.lisp index 9b73c77..fcbff28 100644 --- a/src/packages.lisp +++ b/src/packages.lisp @@ -1,6 +1,6 @@ ;;; -*- mode: lisp -*- -;;; Time-stamp: <2008-11-10 14:52:43 tony> +;;; Time-stamp: <2008-11-12 10:02:03 tony> ;;; Creation: <2008-03-11 19:18:34 user> ;;; File: packages.lisp ;;; Author: AJ Rossini @@ -77,7 +77,8 @@ recursive-map-elements map-elements repeat check-sequence get-next-element make-next-element set-next-element - sequencep iseq ordered-nneg-seq + ;; sequencep + iseq ordered-nneg-seq select split-list which difference rseq flatten-list )) @@ -371,7 +372,8 @@ repeat check-sequence get-next-element make-next-element set-next-element - sequencep iseq + ;; sequencep + iseq ordered-nneg-seq select which difference rseq -- 2.11.4.GIT