Combining Predicates in F#

前端 未结 4 1329
日久生厌
日久生厌 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:13

    Is this what you're looking for?

    > let (&&<) a b x = a x && b x
    
    val ( &&< ) : ('a -> bool) -> ('a -> bool) -> 'a -> bool
    
    > let isBlueCar = isCar &&< isBlue
    
    val isBlueCar : (int -> bool)
    

提交回复
热议问题