This commit is contained in:
Aaro Koivukangas
2025-12-22 21:54:03 +02:00
parent c95f04c031
commit 2b1861a6b0
+2 -2
View File
@@ -49,7 +49,7 @@ twoBananas = MkShoppingEntry "Banana" 1.1 2
-- totalPrice twoBananas ==> 2.2
totalPrice :: ShoppingEntry -> Double
totalPrice = todo
totalPrice (MkShoppingEntry _ price amount) = price * fromIntegral amount
-- buyOneMore should increment the count in an entry by one
--
@@ -57,7 +57,7 @@ totalPrice = todo
-- buyOneMore twoBananas ==> MkShoppingEntry "Banana" 1.1 3
buyOneMore :: ShoppingEntry -> ShoppingEntry
buyOneMore = todo
buyOneMore (MkShoppingEntry name price amount) = MkShoppingEntry name price $ amount+1
------------------------------------------------------------------------------
-- Ex 4: define a datatype Person, which should contain the age (an