luckymerlin
02/28/2017, 6:28 AMaimozg
02/28/2017, 7:43 AM(T,T)->T
functions - are there any case where they might return anything but one of their arguments?inline fun<T> (()->Boolean).asChoice(a:T,b:T):T = if (this()) a else b
fun <U> weirdChoice(random:()->Boolean, c1: U, c2: U): U {
if (random.asChoice(true, false)) {
return random.asChoice(c1, c2)
} else {
return random.asChoice(c2, c1)
}
}
luckymerlin
03/01/2017, 4:49 AM()->Boolean
. Thanks for your detailed explanation. 😄