Question
Haskell program Assume your cat gained a lot of weight since the beginning of the pandemic. Your veterinarianrecommended you keep track of the number of
Haskell program
Assume your cat gained a lot of weight since the beginning of the pandemic. Your veterinarianrecommended you keep track of the number of cat food cans you feed to your pet every month. In addition, they recommended you balance their diet and avoid giving the same types of flavors. So, you start recording how many cans you feed to your cat in a Haskell list. This list logs the number of cans your cat consumed during that month for each flavor.
First consider the food you give to your cat during a single month,
for example: feedinglog =[("Oceanfish",7),( "Tuna",1),( "Whitefish",3),( "Chicken",4),( "Beef",2)]
feedinglog is a list of (flavor, number of cans) pairs.
Write a function cansInLog that takes a months feeding log as input and returns the total number of cans consumed.
The type for countInLogshould be compatible with the following:cansInLog :: Num p => [(a, p)] -> p
Examples:>cansInLog [("Oceanfish",7),("Tuna",1),("Whitefish",3),("Chicken",4),("Beef",2)
return 17
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started