user6540722
user6540722

Reputation:

Transpose a length and filter to just a foldr

I have this function :

count :: Int -> [(Float,Int)] -> Int
count n p = length $ filter ((==n).snd) p

and I want to transpose it to a foldr but im having troubles with the lambda function

Upvotes: 0

Views: 130

Answers (1)

phynfo
phynfo

Reputation: 4938

Try this:

count n = foldr (\(f,i) j -> if (i==n) then j+1 else j) 0

Upvotes: 1

Related Questions