How do you combine filter conditions

后端 未结 4 1484
悲哀的现实
悲哀的现实 2021-02-02 09:42

The filter class of functions takes a condition (a -> Bool) and applies it when filtering.

What is the best way to use a filter on when you have multiple conditions?

4条回答
  •  一生所求
    2021-02-02 10:13

    Well, you can combine functions however you want in Haskell (as long as the types are correct) and using lambdas you don't even have to name your predicate function, i.e.,

    filter (\x -> odd x && x > 100) [1..200]
    

提交回复
热议问题