scala - reversing the boolean return type from a function -
i have 2 functions accept function type: int => boolean function type
def myfunction1(f1: int => boolean) ... def myfunction2(f2: int => boolean) ... i want call function2 function1 instead of invoking f1, want invoke inverse of f1. if f1
(x: int) => x > 4 at runtime, i.e. return true numbers greater four. want reverse returns false if numbers greater four. possible inverse f1 before calling myfunction2?
you this:
def myfunction1(f1: int => boolean) = myfunction2(!f1(_))
Comments
Post a Comment