Page 1 sur 1

is_array? command

Publié : jeu. nov. 29, 2018 7:09 pm
par XcasEngGuy
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

Re: is_array? command

Publié : ven. nov. 30, 2018 9:20 am
par lukamar
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:

Code : Tout sélectionner

if type(arg)==7 then
  \\ arg is a vector
else
  \\ arg is not a vector
fi;

Re: is_array? command

Publié : dim. déc. 02, 2018 9:25 pm
par XcasEngGuy
Thank you very much.

Matt