mirror of
https://github.com/iritmaximus/haskell.git
synced 2026-10-12 19:13:39 +03:00
5a ex3
This commit is contained in:
+2
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user