mirror of
https://github.com/DanilaFe/abacus
synced 2026-01-31 19:15:20 +00:00
Format newly written code.
This commit is contained in:
@@ -10,4 +10,4 @@ package org.nwapw.abacus.function
|
||||
* @param precedence the precedence of this operator, used for order of operations.
|
||||
*/
|
||||
open class Operator(val associativity: OperatorAssociativity, val type: OperatorType,
|
||||
val precedence: Int)
|
||||
val precedence: Int)
|
||||
@@ -8,7 +8,7 @@ package org.nwapw.abacus.function.applicable
|
||||
* @param <T> the type of the parameters passed to this applicable.
|
||||
* @param <O> the return type of the applicable.
|
||||
*/
|
||||
interface Applicable<in T: Any, out O: Any> {
|
||||
interface Applicable<in T : Any, out O : Any> {
|
||||
|
||||
/**
|
||||
* Checks if the given applicable can be used with the given parameters.
|
||||
@@ -16,6 +16,7 @@ interface Applicable<in T: Any, out O: Any> {
|
||||
* @return whether the array can be used with applyInternal.
|
||||
*/
|
||||
fun matchesParams(params: Array<out T>): Boolean
|
||||
|
||||
/**
|
||||
* Applies the applicable object to the given parameters,
|
||||
* without checking for compatibility.
|
||||
@@ -32,7 +33,7 @@ interface Applicable<in T: Any, out O: Any> {
|
||||
* @return the result of the operation, or null if parameters do not match.
|
||||
*/
|
||||
fun apply(vararg params: T): O? {
|
||||
if(!matchesParams(params)) return null
|
||||
if (!matchesParams(params)) return null
|
||||
return applyInternal(params)
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import org.nwapw.abacus.tree.Reducer
|
||||
* @param <O> the return type of the application.
|
||||
* @param <R> the required type of the reducer.
|
||||
*/
|
||||
interface ReducerApplicable<in T: Any, out O: Any, in R: Any> {
|
||||
interface ReducerApplicable<in T : Any, out O : Any, in R : Any> {
|
||||
|
||||
/**
|
||||
* Checks if this applicable can be applied to the
|
||||
@@ -19,6 +19,7 @@ interface ReducerApplicable<in T: Any, out O: Any, in R: Any> {
|
||||
* @param params the parameters to check.
|
||||
*/
|
||||
fun matchesParams(params: Array<out T>): Boolean
|
||||
|
||||
/**
|
||||
* Applies this applicable to the given arguments, and reducer.
|
||||
* @param reducer the reducer to use in the application.
|
||||
@@ -26,6 +27,7 @@ interface ReducerApplicable<in T: Any, out O: Any, in R: Any> {
|
||||
* @return the result of the application.
|
||||
*/
|
||||
fun applyWithReducerInternal(reducer: Reducer<R>, params: Array<out T>): O?
|
||||
|
||||
/**
|
||||
* Applies this applicable to the given arguments, and reducer,
|
||||
* if the arguments and reducer are compatible with this applicable.
|
||||
@@ -34,7 +36,7 @@ interface ReducerApplicable<in T: Any, out O: Any, in R: Any> {
|
||||
* @return the result of the application, or null if the arguments are incompatible.
|
||||
*/
|
||||
fun applyWithReducer(reducer: Reducer<R>, vararg params: T): O? {
|
||||
if(!matchesParams(params)) return null
|
||||
if (!matchesParams(params)) return null
|
||||
return applyWithReducerInternal(reducer, params)
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ abstract class CallNode(val callTo: String) : TreeNode() {
|
||||
val buffer = StringBuffer()
|
||||
buffer.append(callTo)
|
||||
buffer.append("(")
|
||||
for(i in 0 until children.size){
|
||||
for (i in 0 until children.size) {
|
||||
buffer.append(children[i].toString())
|
||||
buffer.append(if(i != children.size - 1) ", " else ")")
|
||||
buffer.append(if (i != children.size - 1) ", " else ")")
|
||||
}
|
||||
return buffer.toString()
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.nwapw.abacus.tree
|
||||
|
||||
import org.nwapw.abacus.number.NumberInterface
|
||||
|
||||
/**
|
||||
* A tree node that holds a single number value.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user