![]()
|
Go to the first, previous, next, last section, table of contents.
オプション指定ユーザ定義関数が N 変数で宣言された場合, その関数は, N 変数での呼び出しのみが許される.
[0] def factor(A) { return fctr(A); }
[1] factor(x^5-1,3);
evalf : argument mismatch in factor()
return to toplevel
不定個引数の関数をユーザ言語で記述したい場合, リスト, 配列を用いることで 可能となるが, 次のようなより分かりやすい方法も可能である.
% 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]]
2 番目の [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. |