Sam
09/17/2018, 3:40 PMSam
09/17/2018, 3:40 PMdiesieben07
09/17/2018, 3:42 PMpredicate
). It then returns a third lambda, which will take a collection as it's parameter and then return that collection filtered by the predicate
.diesieben07
09/17/2018, 3:44 PMfun createFilterFunction(predicate: (Int) -> Boolean): (List<Int>) -> List<Int> {
return { collection: List<Int> ->
collection.filter(predicate)
}
}
robin
09/17/2018, 3:48 PMSam
09/17/2018, 3:56 PMSam
09/17/2018, 4:26 PMval testNestedLambda = { input : () -> () -> Unit -> {
println("executing returned lambda")
input()() }
}
val returnedLambda = testNestedLambda{ { println( "passed lambda") } }
returnedLambda()
Sam
09/17/2018, 4:27 PMSam
09/17/2018, 4:36 PMSam
09/17/2018, 5:12 PMval filter : ( (Int) -> Boolean ) -> ( List<Int> ) -> List<Int> = { predicate -> { collection ->
collection.filter( predicate )
}
}
Sam
09/17/2018, 5:13 PM