use of org.matheclipse.core.interfaces.IBuiltInSymbol in project symja_android_library by axkr.
the class TeXFormFactory method convertInequality.
private boolean convertInequality(final StringBuilder buf, final IAST inequality, final int precedence) {
StringBuilder tempBuffer = new StringBuilder();
if (Precedence.EQUAL < precedence) {
tempBuffer.append("(");
}
final int listSize = inequality.size();
int i = 1;
while (i < listSize) {
convertInternal(tempBuffer, inequality.get(i++), 0);
if (i == listSize) {
if (Precedence.EQUAL < precedence) {
tempBuffer.append(")");
}
buf.append(tempBuffer);
return true;
}
IExpr head = inequality.get(i++);
if (head.isBuiltInSymbol()) {
int id = ((IBuiltInSymbol) head).ordinal();
switch(id) {
case ID.Equal:
tempBuffer.append(" == ");
break;
case ID.Greater:
tempBuffer.append(" > ");
break;
case ID.GreaterEqual:
tempBuffer.append("\\geq ");
break;
case ID.Less:
tempBuffer.append(" < ");
break;
case ID.LessEqual:
tempBuffer.append("\\leq ");
break;
case ID.Unequal:
tempBuffer.append("\\neq ");
break;
default:
return false;
}
} else {
return false;
}
}
if (Precedence.EQUAL < precedence) {
tempBuffer.append(")");
}
buf.append(tempBuffer);
return true;
}
use of org.matheclipse.core.interfaces.IBuiltInSymbol in project symja_android_library by axkr.
the class MathMLFormFactory method convertInequality.
private boolean convertInequality(final StringBuilder buf, final IAST inequality, final int precedence) {
StringBuilder tempBuffer = new StringBuilder();
tagStart(tempBuffer, "mrow");
if (Precedence.EQUAL < precedence) {
// append(buf, "(");
tag(tempBuffer, "mo", "(");
}
final int listSize = inequality.size();
int i = 1;
while (i < listSize) {
convertInternal(tempBuffer, inequality.get(i++), Precedence.EQUAL, false);
if (i == listSize) {
if (Precedence.EQUAL < precedence) {
// append(buf, ")");
tag(tempBuffer, "mo", ")");
}
tagEnd(tempBuffer, "mrow");
buf.append(tempBuffer);
return true;
}
IExpr head = inequality.get(i++);
if (head.isBuiltInSymbol()) {
int id = ((IBuiltInSymbol) head).ordinal();
switch(id) {
case ID.Equal:
tag(tempBuffer, "mo", "==");
break;
case ID.Greater:
tag(tempBuffer, "mo", ">");
break;
case ID.GreaterEqual:
tag(tempBuffer, "mo", ">=");
break;
case ID.Less:
tag(tempBuffer, "mo", "<");
break;
case ID.LessEqual:
tag(tempBuffer, "mo", "<=");
break;
case ID.Unequal:
tag(tempBuffer, "mo", "!=");
break;
default:
return false;
}
} else {
return false;
}
}
if (Precedence.EQUAL < precedence) {
// append(buf, ")");
tag(tempBuffer, "mo", ")");
}
tagEnd(tempBuffer, "mrow");
buf.append(tempBuffer);
return true;
}
use of org.matheclipse.core.interfaces.IBuiltInSymbol in project symja_android_library by axkr.
the class Documentation method getMarkdown.
/**
* Get the pure <code>markdown</code> formatted information about the <code>builinFunctionName
* </code>
*
* @param out
* @param builinFunctionName
* @return
*/
public static boolean getMarkdown(Appendable out, String builinFunctionName) {
ISymbol symbol = F.symbol(builinFunctionName);
String url = null;
if (symbol instanceof IBuiltInSymbol) {
url = SourceCodeFunctions.functionURL(symbol);
}
// read markdown file
String fileName = buildFunctionFilename(builinFunctionName);
// Get file from resources folder
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
try (BufferedReader f = getResourceReader(classloader, fileName)) {
if (f != null) {
String line;
while ((line = f.readLine()) != null) {
out.append(line);
out.append("\n");
}
if (url != null) {
out.append("[Github master](");
out.append(url);
out.append(")\n\n");
}
return true;
}
} catch (IOException e) {
LOGGER.error("Documentation.getMarkdown() failed", e);
}
return false;
}
use of org.matheclipse.core.interfaces.IBuiltInSymbol in project symja_android_library by axkr.
the class Documentation method printDocumentation.
/**
* Load the documentation from resource folder if available and print to output.
*
* @param symbolName
*/
public static boolean printDocumentation(Appendable out, String symbolName) {
ISymbol symbol = F.symbol(symbolName);
String url = null;
if (symbol instanceof IBuiltInSymbol) {
url = SourceCodeFunctions.functionURL(symbol);
}
// read markdown file
String fileName = buildFunctionFilename(symbolName);
// Get file from resources folder
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
try (BufferedReader f = getResourceReader(classloader, fileName)) {
if (f != null) {
String line;
boolean emptyLine = false;
while ((line = f.readLine()) != null) {
if (line.startsWith("```")) {
continue;
}
if (line.trim().length() == 0) {
if (emptyLine) {
continue;
}
emptyLine = true;
} else {
emptyLine = false;
}
out.append(line);
out.append("\n");
}
if (url != null) {
out.append("[Github master](");
out.append(url);
out.append(")\n\n");
}
return true;
}
} catch (IOException e) {
LOGGER.error("Documentation.printDocumentation() failed", e);
}
return false;
}
Aggregations