diff options
author | colin <colin@cicadas.surf> | 2024-09-08 07:33:21 -0700 |
---|---|---|
committer | colin <colin@cicadas.surf> | 2024-09-08 07:33:21 -0700 |
commit | a0f32d5ac333b88bb294c613698389ac8e687f92 (patch) | |
tree | 326a9268bb3c6567696880db96b4471f312a073c | |
parent | 4fc872fb435f11b8bcc7838c6eff4f6b3b48e60c (diff) |
added sequence-of type
-rw-r--r-- | package.lisp | 1 | ||||
-rw-r--r-- | 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." |