From a0f32d5ac333b88bb294c613698389ac8e687f92 Mon Sep 17 00:00:00 2001 From: colin Date: Sun, 8 Sep 2024 07:33:21 -0700 Subject: added sequence-of type --- package.lisp | 1 + petty-types.lisp | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/package.lisp b/package.lisp index ae36c5c..1bf33cb 100644 --- a/package.lisp +++ b/package.lisp @@ -9,4 +9,5 @@ #:optional ; deftype #:tuple ; deftype #:vector-of ; deftype + #:sequence-of ; deftype #:list-of)) ; deftype diff --git a/petty-types.lisp b/petty-types.lisp index 9f98e78..9392191 100644 --- a/petty-types.lisp +++ b/petty-types.lisp @@ -34,7 +34,7 @@ (or (not len) (= len (length xs))) (every is-type xs))))))))) -(defun ordered-sequence-of (types) +(defun tuple-sequence-predicate-of (types) "Returns the name of a predicate that checks whether its argument is a list of exactly (LENGTH TYPES) members such that the type of the NTH member is the NTH member of TYPES." @@ -63,9 +63,13 @@ member is the NTH member of TYPES." "Type specifier for vectors all of the same TYPE." `(and vector (satisfies ,(sequence-of-predicate-for 'vector type len)))) +(deftype sequence-of (type &optional len) + "Type specifier for vectors all of the same TYPE." + `(and sequence (satisfies ,(sequence-of-predicate-for 'sequence type len)))) + (deftype tuple (&rest types) "Type specifier for a list of specific types" - `(and list (satisfies ,(ordered-sequence-of types)))) + `(and list (satisfies ,(tuple-sequence-predicate-of types)))) (deftype optional (type) "Type specifier for an optional type." -- cgit v1.2.3