From 453cd0ea7715d98d94e834d1aa47f9f6a0d5b6e4 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Fri, 1 Sep 2017 17:14:54 -0700 Subject: [PATCH] Add type aliases for Kotlin and a simple extension function. --- .../main/kotlin/org/nwapw/abacus/number/NumberUtils.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 core/src/main/kotlin/org/nwapw/abacus/number/NumberUtils.kt diff --git a/core/src/main/kotlin/org/nwapw/abacus/number/NumberUtils.kt b/core/src/main/kotlin/org/nwapw/abacus/number/NumberUtils.kt new file mode 100644 index 0000000..5503613 --- /dev/null +++ b/core/src/main/kotlin/org/nwapw/abacus/number/NumberUtils.kt @@ -0,0 +1,10 @@ +@file:JvmName("NumberUtils") +package org.nwapw.abacus.number + +typealias PromotionFunction = java.util.function.Function +typealias PromotionPath = List +typealias NumberClass = Class + +fun PromotionPath.promote(from: NumberInterface): NumberInterface { + return fold(from, { current, function -> function.apply(current) }) +} \ No newline at end of file