I have several filter functions with signature 'a -> bool. I want to create a combined filter that AND's the different filters. I know I can do it like this:
let fCombined x =
f1 x
&& f2 x
&& f3 x
Is there any more concise way to directly compose the functions without fully applying them (e.g. by removing x from the definition of fCombined)?
(I know there are other ways that don't use bool, e.g. by using 'a -> 'a option functions and composing them using Option.bind, but that's hardly more concise.)
If you want to lose the argument x, you can make yourself a special operator:
let (&&.) f g x = f x && g x
let fCombined = f1 &&. f2 &&. f3
But I don't think this is the kind of thing to worry about. Having the argument is totally fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With