📄 isspace.java
字号:
package jmathlib.toolbox.string;
import jmathlib.core.tokens.Token;
import jmathlib.core.tokens.OperandToken;
import jmathlib.core.tokens.numbertokens.*;
import jmathlib.core.functions.ExternalFunction;
import jmathlib.core.tokens.CharToken;
/**An external function for checking on whitespaces */
public class isspace extends ExternalFunction
{
public OperandToken evaluate(Token[] operands)
{
if (getNArgIn(operands)!=1)
throwMathLibException("isspace: number of input arguments != 1");
if ( !(operands[0] instanceof CharToken))
throwMathLibException("isspace: works only on strings");
// get data from arguments
String str = ((CharToken)operands[0]).getValue();
double[][] ret = new double[1][str.length()];
// find all whitespaces
for (int i=0; i<str.length(); i++)
{
char c = str.charAt(i);
if ((c==' ') ||
(c=='\t') ||
(c=='\r') ||
(c=='\n') )
ret[0][i]= 1.0;
}
return new DoubleNumberToken( ret );
} // end eval
}
/*
@GROUP
char
@SYNTAX
isspace()
@DOC
@EXAMPLES
@NOTES
@SEE
letter
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -