mirror of
https://github.com/DanilaFe/abacus
synced 2024-06-23 11:17:06 -07:00
10 lines
312 B
Kotlin
10 lines
312 B
Kotlin
|
package org.nwapw.abacus.tree
|
||
|
|
||
|
data class UnaryNode(val operation: String, val applyTo: TreeNode? = null) : TreeNode() {
|
||
|
|
||
|
override fun <T : Any> reduce(reducer: Reducer<T>): T? {
|
||
|
val reducedChild = applyTo?.reduce(reducer) ?: return null
|
||
|
return reducer.reduceNode(this, reducedChild)
|
||
|
}
|
||
|
|
||
|
}
|