Searching through list

后端 未结 4 878
日久生厌
日久生厌 2021-01-26 14:47

I\'ve been trying to define a function which, given a list of Integers and an Integer n, returns a Boolean indicating whether n occurs exactly once in the list.

I have t

4条回答
  •  情话喂你
    2021-01-26 15:07

    once :: (Eq a) => [a] -> a -> Bool
    once xs x = (== 1) $ length $ filter (== x) xs
    

提交回复
热议问题