I'm trying to recursively count how many times a given element (number) appears in a list.
For example, equals 2 [1,2,3,2,1,2,3] should return 3 for the number of times 2 appears in the list.
What i've done so far:
equals :: Integer -> [Integer] -> Int equals n [] = 0 equals n (x:xs) = if equals n == x then 1 + equals n xs else equals xs https://stackoverflow.com/questions/66037894/haskell-how-to-count-occurance-of-an-element-in-a-list-recursively February 04, 2021 at 08:52AM
没有评论:
发表评论