I would like to test if an argument of a procedure is or not assigned. The result should be like (assuming test is the name of the procedure) :
>un:=1: >test(un) ; true >test(deux); false
The number of arguments is not supposed to be known.
The procedure assigned will indicate whether its argument is assigned, however, in order to use this in a procedure (I assume that you want to do something else) the formal parameter must be typed with uneval, i.e.
test := proc(x::uneval) assigned(x) end:
It isn’t possible, I believe, to handle an indefinite number of arguments.
This function is part of maple and called assigned . Inside a procedure it works with global and local names. But you have to be carfull. Take
f:=proc(x) assigned(x) end; a:=1; f(a); Error, wrong number (or type) of parameters in function assigned
This is because the evaluation of a to 1 take place before the call of f . If you want to pass the variable a (instead of the value of a) to f, you have to use a uneval-quotation in the function call
f('a');
A better way is to declare the parameter of f as an "eval to name"
parameter
f:=proc(x::evaln) assigned(x) end;
Now f(a) gives no problem. I hope this helps.
In rel 5 I make use of the uneval formal parameter type. This passes the name through, eg as ‘x‘ in the example proc below that does what you want I believe, and can be tested with the built in function ‘assigned‘:
> f:=proc(x::uneval)if assigned(x) then ("OK") else ("not OK") fi end: > f(un);f(deux); "OK" "not OK"
However, if you want the value of x you do need to use eval(x) for the value (or eval(x,n), where n is 2 or greater).