Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

Focuses strongly on achievement and success in self and others.

Answered: 1 week ago

Question

Explain the concept of shear force and bending moment in beams.

Answered: 1 week ago

Question

=+When and under what circumstances are contracts renegotiated?

Answered: 1 week ago

Question

=+Are the contracts enforceable?

Answered: 1 week ago