* Tom Russ <50ba9190-a8a2-4036-94c6-b802174e9e60n @
googlegroups.com> :
Wrote on Wed, 29 Jun 2022 15:55:09 -0700 (PDT):
> On Wednesday, June 29, 2022 at 8:02:18 AM UTC-7, ??? wrote:
>> On Wednesday, June 29, 2022 at 9:59:34 AM UTC-4, Alan Bawden wrote:
>> > David Richards ??? writes:
>> > I am expecting the following to return false (NIL). What am I not
>> > understanding? I get the same result in SBCL, CLISP and Allegro-lisp so
>> > clearly it's me!
>> > (typep #("Hello" "world") '(vector number))
>> > T
>> > Because (UPGRADED-ARRAY-ELEMENT-TYPE 'NUMBER) is T, and so (VECTOR NUMBER)
>> > is really just the same as (VECTOR T). If any of those implementations
>> > supported an array type that could _only_ contain numbers (and _not_
>> > strings), then you would get a different answer in that implementation.
>> Thank you Alan for the answer! So if I wanted to make certain that
>> an array holds only strings I'd have to use something like
>> (every 'stringp #("Hello" "World"))
>> right?
>> Thanks!
>Yes.
You can even turn that predicate expression into a type with SATISFIES,
but you need to make it a named function first
(defun all-strings-p (seq)
(every 'stringp seq))
(deftype string-vec ()
`(and vector (satisfies all-strings-p)))
(typep #("Hello World") 'string-vec) ;;=> T