While trying to grasp the potentials of the collection features in F#, I encountered this one:
let needSpecialDocument country = (not country.IsEea) && (not country.IsInSchengen)
// could also be: not (country.IsEea || country.IsInSchengen)
let wantToMoveTo country = country.Name = "CC"
let potentialDestinations =
countries
|> Seq.filter needSpecialDocument2
|> Seq.filter wantToMoveTo
Is there a way to combine the two filters into one? I managed the one below but it feels like there is a more fsharpish way to do so..
|> Seq.filter (fun c -> (needSpecialDocument c) && (wantToMoveTo c))
Test data:
type Country = {Name : string; IsEea : bool; IsInSchengen : bool}
let uk = {Name = "UK"; IsEea = false; IsInSchengen = false}
let ir = {Name = "IR"; IsEea = true; IsInSchengen = false}
let fr = {Name = "FR"; IsEea = true; IsInSchengen = true}
let ch = {Name = "CH"; IsEea = false; IsInSchengen = true}
let cc = {Name = "CC"; IsEea = false; IsInSchengen = false}
let countries = [uk;ir;fr;ch;cc]