Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/muqhc/runction
the library for your enjoyment with functions
https://github.com/muqhc/runction
Last synced: 25 days ago
JSON representation
the library for your enjoyment with functions
- Host: GitHub
- URL: https://github.com/muqhc/runction
- Owner: muqhc
- License: unlicense
- Created: 2021-12-30T13:38:31.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-01-14T11:35:40.000Z (about 3 years ago)
- Last Synced: 2024-12-07T09:25:17.365Z (about 2 months ago)
- Language: Kotlin
- Homepage:
- Size: 111 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Runction
### _the library for your enjoyment with functions_
---## add dependency
### Gradle Kotlin DSL
#### build.gradle.kts
```kotlin
repositories {
mavenCentral()
}dependencies {
implementation("io.github.muqhc:runction:0.3.0")
}
```
### the other ways
* [here](https://search.maven.org/artifact/io.github.muqhc/runction/0.3.0/jar)## and use !
#### Hello.kt
```kotlin
import io.github.muqhc.runction.*
```
---
## example---
#### runc
```kotlin
val plus = runc, Any, Any> { a ->
runc { b ->
a+b
}
}println( plus(2)(7) ) // 2 + 7 = 9
val plusTen = plus(10)
println( plusTen(4) ) // 10 + 4 = 14
```
---
#### decoration
```kotlin
val plus = runc, Any, Any> { a ->
runc { b ->
decoration( a+b )
}
}// decoration(it) = it * it
val plusFourThenPow = plus(4) decorateLeft { it * it }println( plusFourThenPow(5) ) // { it * it }( 4 + 5 ) = 81
```
---
#### bind & composite
```kotlin
val plusTwo = { x: Int -> x + 2 }
val plusTen = { x: Int -> x + 10 }//val plusTwelve = { x -> plusTen( plusTwo( x ) ) }
val plusTwelve = plusTwo composite plusTen //<=> plusTen compositeLeft plusTwo// { x -> println( plusTwelve( x ) ) }.invoke( 6 )
plusTwelve composite ::println bind 6 // output: 18
```
---
#### bindOn & compositeOn
```kotlin
val modulo = runc,Int,Int> { b ->
runc { a ->
a % b == 0
}
}val isOdd = modulo(2) compositeOn { not() }
0..9 bindOn
{ toList() } bindOn
{ this::filter bind isOdd } bind ::println
//output: [1, 3, 5, 7, 9]
```
---
#### boolean expression
```kotlin
( 9 > 8 ) {
ifTrue { "It's True!" bind ::println }
ifFalse { "It's False!" bind ::println }
}
//output: It's True!
```