mirror of
https://github.com/DanilaFe/abacus
synced 2026-01-25 08:05:19 +00:00
Compare commits
6 Commits
java8-subs
...
documentat
| Author | SHA1 | Date | |
|---|---|---|---|
| 0d26167f31 | |||
| 07abe4d17a | |||
| 8ef0904d26 | |||
| 2a9026f748 | |||
| 08e5b69c04 | |||
| 5a1fdfe4bc |
@@ -221,6 +221,13 @@ abstract class NumberInterface: Comparable<NumberInterface> {
|
||||
return fractionalPartInternal()
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given number is an integer or not.
|
||||
*
|
||||
* @return whether the number is an integer or not.
|
||||
*/
|
||||
fun isInteger() = fractionalPart().signum() == 0
|
||||
|
||||
/**
|
||||
* Returns a NumberRangeBuilder object, which is used to create a range.
|
||||
* The reason that this returns a builder and not an actual range is that
|
||||
|
||||
@@ -17,7 +17,7 @@ class OperatorCaret: NumberOperator(OperatorAssociativity.RIGHT, OperatorType.BI
|
||||
override fun matchesParams(context: MutableEvaluationContext, params: Array<out NumberInterface>) =
|
||||
params.size == 2
|
||||
&& !(params[0].signum() == 0 && params[1].signum() == 0)
|
||||
&& !(params[0].signum() == -1 && params[1].fractionalPart().signum() != 0)
|
||||
&& !(params[0].signum() == -1 && !params[1].isInteger())
|
||||
|
||||
override fun applyInternal(context: MutableEvaluationContext, params: Array<out NumberInterface>): NumberInterface {
|
||||
val implementation = context.inheritedNumberImplementation
|
||||
@@ -26,7 +26,7 @@ class OperatorCaret: NumberOperator(OperatorAssociativity.RIGHT, OperatorType.BI
|
||||
else if (params[1].signum() == 0)
|
||||
return implementation.instanceForString("1")
|
||||
//Detect integer bases:
|
||||
if (params[0].fractionalPart().signum() == 0
|
||||
if (params[0].isInteger()
|
||||
&& FUNCTION_ABS.apply(context, params[1]) < implementation.instanceForString(Integer.toString(Integer.MAX_VALUE))
|
||||
&& FUNCTION_ABS.apply(context, params[1]) >= implementation.instanceForString("1")) {
|
||||
val newParams = arrayOf(params[0], params[1].fractionalPart())
|
||||
|
||||
@@ -15,7 +15,7 @@ class OperatorFactorial: NumberOperator(OperatorAssociativity.LEFT, OperatorType
|
||||
|
||||
override fun matchesParams(context: MutableEvaluationContext, params: Array<out NumberInterface>) =
|
||||
params.size == 1
|
||||
&& params[0].fractionalPart().signum() == 0
|
||||
&& params[0].isInteger()
|
||||
&& params[0].signum() >= 0
|
||||
|
||||
override fun applyInternal(context: MutableEvaluationContext, params: Array<out NumberInterface>): NumberInterface {
|
||||
|
||||
@@ -16,8 +16,8 @@ import org.nwapw.abacus.plugin.standard.StandardPlugin.*
|
||||
class OperatorNcr: NumberOperator(OperatorAssociativity.RIGHT, OperatorType.BINARY_INFIX, 0) {
|
||||
|
||||
override fun matchesParams(context: MutableEvaluationContext, params: Array<out NumberInterface>) =
|
||||
params.size == 2 && params[0].fractionalPart().signum() == 0
|
||||
&& params[1].fractionalPart().signum() == 0
|
||||
params.size == 2 && params[0].isInteger()
|
||||
&& params[1].isInteger()
|
||||
|
||||
override fun applyInternal(context: MutableEvaluationContext, params: Array<out NumberInterface>) =
|
||||
OP_NPR.apply(context, *params) / OP_FACTORIAL.apply(context, params[1])
|
||||
|
||||
@@ -15,8 +15,8 @@ import org.nwapw.abacus.number.NumberInterface
|
||||
class OperatorNpr: NumberOperator(OperatorAssociativity.RIGHT, OperatorType.BINARY_INFIX, 0) {
|
||||
|
||||
override fun matchesParams(context: MutableEvaluationContext, params: Array<out NumberInterface>) =
|
||||
params.size == 2 && params[0].fractionalPart().signum() == 0
|
||||
&& params[1].fractionalPart().signum() == 0
|
||||
params.size == 2 && params[0].isInteger()
|
||||
&& params[1].isInteger()
|
||||
|
||||
override fun applyInternal(context: MutableEvaluationContext, params: Array<out NumberInterface>): NumberInterface {
|
||||
val implementation = context.inheritedNumberImplementation
|
||||
|
||||
@@ -359,10 +359,13 @@ public class AbacusController implements PluginListener {
|
||||
if(documentationInstance == null)
|
||||
documentationInstance = new Documentation(name, "", "", "", DocumentationType.FUNCTION);
|
||||
return documentationInstance;
|
||||
})
|
||||
.collect(Collectors.toCollection(ArrayList::new)));
|
||||
functionList.addAll(manager.getAllTreeValueFunctions().stream().map(name -> pluginManager.documentationFor(name, DocumentationType.TREE_VALUE_FUNCTION))
|
||||
.collect(Collectors.toCollection(ArrayList::new)));
|
||||
}).collect(Collectors.toCollection(ArrayList::new)));
|
||||
functionList.addAll(manager.getAllTreeValueFunctions().stream().map(name -> {
|
||||
Documentation documentationInstance = pluginManager.documentationFor(name, DocumentationType.TREE_VALUE_FUNCTION);
|
||||
if(documentationInstance == null)
|
||||
documentationInstance = new Documentation(name, "", "", "", DocumentationType.TREE_VALUE_FUNCTION);
|
||||
return documentationInstance;
|
||||
}).collect(Collectors.toCollection(ArrayList::new)));
|
||||
functionList.sort(Comparator.comparing(Documentation::getCodeName));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user