![]()
|
Go to the first, previous, next, last section, table of contents.
optionIf a user defined function is declared with N arguments, then the function is callable with N arguments only.
[0] def factor(A) { return fctr(A); }
[1] factor(x^5-1,3);
evalf : argument mismatch in factor()
return to toplevel
A function with indefinite number of arguments can be realized by using a list or an array as its argument. Another method is available as follows:
% cat factor
def factor(F)
{
Mod = getopt(mod);
ModType = type(Mod);
if ( ModType == 1 ) /* 'mod' is not specified. */
return fctr(F);
else if ( ModType == 0 ) /* 'mod' is a number */
return modfctr(F,Mod);
}
[0] load("factor")$
[1] factor(x^5-1);
[[1,1],[x-1,1],[x^4+x^3+x^2+x+1,1]]
[2] factor(x^5-1|mod=11);
[[1,1],[x+6,1],[x+2,1],[x+10,1],[x+7,1],[x+8,1]]
In the second call of [100] xxx(1,2,x^2-1,[1,2,3]|proc=1,index=5); Go to the first, previous, next, last section, table of contents. |