2025-12-12 Class and Instance Review
-
Make a class
Foodso that whenais aFood, thenahas a functioncalories :: a -> Intand a functiontaste :: a -> String. -
Make
Stringan instance ofFood. Use 15 * length for calories and “Yummy " followed by the string for the taste. -
Make a data type
StirFrythat contains both anIntvariablericeand a[String]calleding(for ingredients). -
Make
StirFryan instance ofFood. For calories, use the sum of the calories of the Food in the list, plus 20 times the rice. For taste, use “StirFry of x,y,z” (see question 5). -
Write the
commasfunction shown below.commas :: [String] -> String test_commas = commas ["a","beta","c"] == "a,beta,c"Use recursion.