forked from kscience/kmath
Add curring and update kotlin
This commit is contained in:
parent
f1435c2c05
commit
de3c2a1b5a
@ -22,10 +22,22 @@ public interface Algebra<T> {
|
|||||||
*/
|
*/
|
||||||
public fun unaryOperation(operation: String, arg: T): T
|
public fun unaryOperation(operation: String, arg: T): T
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Currying version of [unaryOperation]
|
||||||
|
*/
|
||||||
|
public fun unaryOperationFunction(operation: String): (T) -> T = { unaryOperation(operation, it) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dynamic call of binary operation [operation] on [left] and [right]
|
* Dynamic call of binary operation [operation] on [left] and [right]
|
||||||
*/
|
*/
|
||||||
public fun binaryOperation(operation: String, left: T, right: T): T
|
public fun binaryOperation(operation: String, left: T, right: T): T
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Curring version of [binaryOperation]
|
||||||
|
*/
|
||||||
|
public fun binaryOperationFunction(operation: String): (left: T, right: T) -> T = { left, right ->
|
||||||
|
binaryOperation(operation, left, right)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,11 +57,27 @@ public interface NumericAlgebra<T> : Algebra<T> {
|
|||||||
public fun leftSideNumberOperation(operation: String, left: Number, right: T): T =
|
public fun leftSideNumberOperation(operation: String, left: Number, right: T): T =
|
||||||
binaryOperation(operation, number(left), right)
|
binaryOperation(operation, number(left), right)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Curring version of [leftSideNumberOperation]
|
||||||
|
*/
|
||||||
|
public fun leftSideNumberOperationFunction(operation: String): (left: Number, right: T) -> T =
|
||||||
|
{ left: Number, right: T ->
|
||||||
|
leftSideNumberOperation(operation, left, right)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dynamic call of binary operation [operation] on [left] and [right] where right element is [Number].
|
* Dynamic call of binary operation [operation] on [left] and [right] where right element is [Number].
|
||||||
*/
|
*/
|
||||||
public fun rightSideNumberOperation(operation: String, left: T, right: Number): T =
|
public fun rightSideNumberOperation(operation: String, left: T, right: Number): T =
|
||||||
leftSideNumberOperation(operation, right, left)
|
leftSideNumberOperation(operation, right, left)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Curring version of [rightSideNumberOperation]
|
||||||
|
*/
|
||||||
|
public fun rightSideNumberOperationFunction(operation: String): (left: T, right: Number) -> T =
|
||||||
|
{ left: T, right: Number ->
|
||||||
|
rightSideNumberOperation(operation, left, right)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -8,8 +8,8 @@ pluginManagement {
|
|||||||
maven("https://dl.bintray.com/kotlin/kotlinx")
|
maven("https://dl.bintray.com/kotlin/kotlinx")
|
||||||
}
|
}
|
||||||
|
|
||||||
val toolsVersion = "0.7.0"
|
val toolsVersion = "0.7.1"
|
||||||
val kotlinVersion = "1.4.20"
|
val kotlinVersion = "1.4.21"
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("kotlinx.benchmark") version "0.2.0-dev-20"
|
id("kotlinx.benchmark") version "0.2.0-dev-20"
|
||||||
|
Loading…
Reference in New Issue
Block a user