Question: Why is this type check not working?

I use this type ckect elsewhere inside a package and it works. I can't get it to work in a stand alone procedure.

This was originally provided by @acer (best answer) in this question Experimental format for projective vectors - MaplePrimes

restart

 

 

test:=proc(V::{And('Vector(1)',satisfies( v->type(v[1],'Vector[:-column](3)') ) ),
               And('Vector(1)',satisfies( v->type(v[1],'Vector[:-row](3)') ) )})
print("works",V);
end proc

proc (V::{And('Vector(1)', satisfies(proc (v) options operator, arrow; type(v[1], 'Vector[:-column](3)') end proc)), And('Vector(1)', satisfies(proc (v) options operator, arrow; type(v[1], 'Vector[:-row](3)') end proc))}) print("works", V) end proc

(1)

v1:=<[<1,3,2>]>;
v2:=<[<a|b|c>]>

Vector(1, {(1) = Vector(3, {(1) = 1, (2) = 3, (3) = 2})})

 

Vector[column](%id = 36893490573309309044)

(2)

test(v1)

Error, invalid input: test expects its 1st argument, V, to be of type {And('Vector[1]',satisfies(v -> type(v[1],'Vector[:-column](3)'))), And('Vector[1]',satisfies(v -> type(v[1],'Vector[:-row](3)')))}, but received Vector(1, [Vector(3, [1,3,2])])

 

test(v2)

Error, invalid input: test expects its 1st argument, V, to be of type {And('Vector[1]',satisfies(v -> type(v[1],'Vector[:-column](3)'))), And('Vector[1]',satisfies(v -> type(v[1],'Vector[:-row](3)')))}, but received Vector(1, [Vector[row](3, [a,b,c])])

 

whattype(v1)

Vector[column]

(3)

whattype(v1[1])

Vector[column]

(4)

whattype(v2)

Vector[column]

(5)

whattype(v2[1])

Vector[row]

(6)
 

 

Download 2024-12-29_Q_Type_checking_not_working.mw

Please Wait...