restart;
MyTypes := {algebraic, ''[algebraic$_], 'Vector(_, algebraic)'''$_ = 2 .. 3};
TypeTools:-AddType(MyType, MyTypes);
MyProc := proc (Q1::(depends(And(MyType, satisfies(proc (Q1) options operator, arrow; andmap(proc (T) options operator, arrow; Q1::T implies Q2::T and Q3::T end proc, MyTypes) end proc)))), Q2, Q3) if Q1::algebraic then print('algebraic*inputs') elif Q1::[algebraic$2] then print('List*inputs', 2, 'elements') elif Q1::[algebraic$3] then print('List*inputs', 3, 'elements') elif Q1::'Vector(2, algebraic)' then print('vector', 2) else Q1::'Vector(3, algebraic)'; print('vector', 3) end if end proc;
MyProc(sqrt(1-2*x), 2*x, 3);
algebraic inputs
MyProc([1, x], [2, 3], [1, sqrt(1-2*x)]);
List inputs, 2, elements
MyProc([1, x, 1], [2, 3, 2], [1, sqrt(1-2*x), 2]);
List inputs, 3, elements
MyProc(`<,>`(1, 1), `<,>`(2, 3), `<,>`(1, 2));
vector, 2
MyProc(`<,>`(1, 2), `<,>`(2, 3), `<,>`(1, 2));
proc(n, f, t) ... end;, 2
MyProc(`<,>`(1, 2, 3), `<,>`(2, 3, 6), `<,>`(1, -5, 2));
proc(n, f, t) ... end;, 3
MyProc(`<,>`(1, x, 1), `<,>`(2, 3, 3), `<,>`(1, 2, 7));
proc(n, f, t) ... end;, 3
MyProc(sqrt(1-2*x), 2, [3, 1]);
Error, invalid input: MyProc expects its 1st argument, Q1, to be of type And(MyType, satisfies(proc (Q1) options operator, arrow; andmap(proc (T) options operator, arrow; Q1::T implies Q2::T and Q3::T end proc, MyTypes) end proc)), but received (1-2*x)^(1/2)
MyProc([1, `<,>`(2)], [sqrt(1-2*x), 3], [1, 2]);
Error, invalid input: MyProc expects its 1st argument, Q1, to be of type And(MyType, satisfies(proc (Q1) options operator, arrow; andmap(proc (T) options operator, arrow; Q1::T implies Q2::T and Q3::T end proc, MyTypes) end proc)), but received [1, Vector(1, {(1) = 2})]

@Carl Love I have made some progress with understanding this. I can see how it works. It does seem to have a problem with Vectors. Get this as an output.

proc(n, f, t) ... end;, 2

Sometimes it works with vectors.

I want to put this set of "types" into Packege. Obiviously the most efficient thing is the types get defined globally at the start of the package and then can be used as needed in individual procedures in the package. I tried placing part of your 1st answer into the package.

**uses TT= TypeTools;**

global _T1, _T2L, _T2V, _T3L, _T3V, _MyType;

local

MyTypes:= {_T1, _T2L, _T2V, _T3L, _T3V},

AllMyTypes:= MyTypes union {_MyType},

** ModuleLoad:= proc()**

local

g, #iterator over module globals

e

;

#op([2,6], ...) of a module is its globals.

for g in op([2,6], thismodule) do

e:= eval(g);

if g <> e and e in AllMyTypes then

error "The name %1 must be globally available.", g

end if

end do;

TT:-AddType(_T1, algebraic);

TT:-AddType(_T2V, 'Vector(2, algebraic)');

TT:-AddType(_T2L, [algebraic $ 2]);

TT:-AddType(_T3V, 'Vector(3, algebraic)');

TT:-AddType(_T3L, [algebraic $ 3]);

TT:-AddType(_MyType, MyTypes)

end proc,

**That didn't work. I don't know how much of it I need. Do I need to use all of the module on procedures that check input types**

**You 1st answer works fine with the tested inputs on the vectors**. I found if I only enter 2 parameters it crashes Maple, looses kernel connection.

This leads to another question. Can a procedure have a variable number of imputs? Outside of putting them in a list first. An axample here would be angle formed be 3 points or 2 vectors or 2 lines.

Could an input be allowed to be Null? Or C takes on a default value is not entered.

Just to note here. Only some of the procedures in the package need to test the input parameters and usually not all types would need to be tested.

** **