-
Notifications
You must be signed in to change notification settings - Fork 72
Reverse
Boris Kheyfets edited this page Oct 13, 2020
·
3 revisions
The reverse()
function (named "flip" in other languages) returns the same function with its parameters in reverse order
val f = {(s:String, i:Int, l:List<Long>) -> /* */}
val r:(List<Long>,Int,String) -> Unit = f.reverse()
Kotlin 1.4 script for Unix-like OS:
#!/usr/bin/env kotlin
@file:Repository("https://jcenter.bintray.com")
@file:DependsOn("org.funktionale:funktionale-all:1.2")
import org.funktionale.reverse.*
val f: (String, Int, List<Long>) -> Unit = { s, i, l -> println("$s, $i, $l") }
f("s", 3, listOf(1L,2L))
val r: (List<Long>, Int, String) -> Unit = f.reverse()
r(listOf(1L,2L), 3, "s")