Creating a negated predicate in F#
f#
Solution
What you are trying to do is called "function composition". Check out the function composition operator of f#:
- In F# what does the >> operator mean?
I don't have a compiler available to experiment, but you could start from
let otherFunc = myFunc >> not
and work your way through errors.
EDIT: Max Malook points out that this will not work with the current definition of `myFunc`, because it takes two arguments (in a sense, this is functional-land). So, in order to make this work, `myFunc` would need to change into accepting a Tuple:
let myFunc (a, b) = a > b
let otherFunc = myFunc >> not
let what = otherFunc (3, 4)
Problem
I have a predicate in F# for example ``` let myFunc x y = x < y ``` Is there a way to create the negated version of this function? So something that would be functionally similar to ``` let otherFunc x y = x >= y ``` But by using the original myFunc? ``` let otherFunc = !myFunc // not valid ```