1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-07-01 23:06:11 -07:00
Abacus/core/src/main/kotlin/org/nwapw/abacus/tree/NumberUnaryNode.kt

19 lines
579 B
Kotlin
Raw Normal View History

package org.nwapw.abacus.tree
/**
* A unary operator node that reduces its children.
*
* NumberUnaryNode operates by simply reducing its child,
* and using the result of that reduction to reduce itself.
* @param operation the operation this node performs.
* @param child the child this node should be applied to.
*/
2017-09-07 12:31:40 -07:00
class NumberUnaryNode(operation: String, child: TreeNode)
: UnaryNode(operation, child) {
override fun <T : Any> reduce(reducer: Reducer<T>): T? {
2017-09-07 12:31:40 -07:00
val child = applyTo.reduce(reducer)
return reducer.reduceNode(this, child)
}
}