Combining Predicates in F#

前端 未结 4 1330
日久生厌
日久生厌 2021-02-18 17:44

Is there a standard way of logically combining predicates in F#? For example, let\'s say I have isCar x and isBlue x then I want something that gives m

4条回答
  •  难免孤独
    2021-02-18 18:19

    You could define a combinator.

    let (<&>) f g = (fun x -> f x && g x)
    

    then do

    let isBlueCar = isCar <&> isBlue
    

提交回复
热议问题