partial-function-kt

This library provides Scala's PartialFunction and a set of functions that take it as an argument in Kotlin.
Partial functions are those that might not provide an answer for every possible input, unlike total functions which offer a result for each input.
Getting Started
Requirements
Installation
Gradle
Add the dependency to your project:
dependencies {
implementation("com.jsoizo:partial-function-kt:0.1.1")
}
Usage
To define a PartialFunction
val devide = partialFunction<Int, Int>(
{ it != 0 },
{ 42 / it }
)
To chain PartialFunctions for complex logic
val add100 = partialFunction<Int, Int>(
{ it >= 0 },
{ it + 100 }
)
val devide42AndAdd100 = devide42 andThen add100
val devide42OrAdd100 = devide42 orElse add100
To use the defined PartialFunction with Array, Result, or Nullable operations
val numbers = listOf(1, 2, 0, -4, -3)
val collected = numbers.collect(devide42AndAdd100)
License
This project is licensed under the MIT License.