isfunctionhandle.java

来自「JAVA 数学程序库 提供常规的数值计算程序包」· Java 代码 · 共 44 行

JAVA
44
字号
package jmathlib.toolbox.general;

import jmathlib.core.tokens.numbertokens.DoubleNumberToken;
import jmathlib.core.tokens.Token;
import jmathlib.core.tokens.OperandToken;
import jmathlib.core.tokens.FunctionHandleToken;
import jmathlib.core.functions.ExternalFunction;

/**External function to check if an argument is of type function hanlde*/
public class isfunctionhandle extends ExternalFunction
{
	/**@param operands[0] = a matrix of numbers
	@return a matrix the same size with 1 if the number is a prime*/
	public OperandToken evaluate(Token[] operands)
	{
        if (getNArgIn(operands) != 1)
			throwMathLibException("isfunctionhandle: number of arguments != 1");
            
	    if (operands[0] instanceof FunctionHandleToken) 
	        return new DoubleNumberToken(1.0);
	    else
            return new DoubleNumberToken(0.0);

	}
	
}

/*
@GROUP
general
@SYNTAX
answer=isfunctionhandle(value)
@DOC
Checks if value is a function handle. Returning 1 if it is.
@EXAMPLES
<programlisting>
isfunctionhandle( @sin ) -> 1
</programlisting>
@NOTES
@SEE
isa
*/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?