From 77d96effd62879b405986a68725181ac61d2394a Mon Sep 17 00:00:00 2001 From: AJ Rossini Date: Mon, 25 Jun 2007 08:47:34 +0200 Subject: [PATCH] start the transport of sequence support from LispStat to CommonLisp --- sequence.lsp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/sequence.lsp b/sequence.lsp index 931c24c..9f87639 100644 --- a/sequence.lsp +++ b/sequence.lsp @@ -25,15 +25,23 @@ ;;; Sequences are part of ANSI CL, being a supertype of vector and ;;; list (ordered set of things). +;;; +;;; Need to use the interenal structure when possible -- silly to be +;;; redundant! + ;;; Type Checking Functions (defun check-sequence (a) - (if (not (or (vectorp a) (consp a))) + ;; FIXME:AJR: does this handle consp as well? (Luke had an "or" + ;; with consp). + (if (not (typep a 'sequence)) (error "not a sequence - ~s" a))) ;;; Sequence Element Access + +;;; (elt x i) -- NOT. This is more like "pop". (defun get-next-element (x i) "Get element i from seq x. FIXME: not really??" (let ((myseq (first x))) @@ -43,6 +51,7 @@ elem) (aref myseq i)))) +;;; (setf (elt x i) v) (defun set-next-element (x i v) (let ((seq (first x))) (cond ((consp seq) @@ -56,11 +65,9 @@ ;;; Sequence Functions -(defun sequencep (x) -"Args: (x) -Returns NIL unless X is a list or vector." - (or (listp x) (vectorp x))) - +;; to prevent breakage. +(defmacro sequencep (x) + (typep x 'sequence)) (defun iseq (a &optional b) "Args: (n &optional m) -- 2.11.4.GIT