Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- count:: [a] -> Int
- count [] = 0
- count (x:xs) = 1 + count xs
- _count:: Num b => b -> [a] -> b
- _count b [] = b
- _count b (x:xs) = _count (b + 1) xs
- count:: [a] -> Int
- count = _count 0
- myfold:: (b -> a -> b) -> b -> [a] -> b
- myfold f b [] = b
- myfold f b (x:xs) = myfold f (f b x) xs
- count = myfold incr 0
- where incr c _ = c + 1
- myfoldr:: (a -> b -> b) -> b -> [a] -> b
- myfoldr f b [] = b
- myfoldr f b (x:xs) = f x (myfoldr f b xs)
Add Comment
Please, Sign In to add comment