Is there a command in xcas programming to test if a variable contains an array or a single value? I would like to write functions that can operate on a single equation or multiple equations in an array. For example:
function(z=x+y)
or
function([z=x+y,z=3*x+4*y])
I would like to be able to determine inside the function whether there is one equation or an array of equations.
Thank you
Matt
is_array? command
Modérateur : xcasadmin
Re: is_array? command
Hi,
perhaps you can use type command. If the argument for your function is arg, then type(arg) should return the integer 7 (meaning 'vector') only when arg is a vector. Hence you can use the following conditional switch:
perhaps you can use type command. If the argument for your function is arg, then type(arg) should return the integer 7 (meaning 'vector') only when arg is a vector. Hence you can use the following conditional switch:
Code : Tout sélectionner
if type(arg)==7 then
\\ arg is a vector
else
\\ arg is not a vector
fi;
-
- Messages : 146
- Inscription : mer. janv. 13, 2010 3:20 pm
Re: is_array? command
Thank you very much.
Matt
Matt