Here are the Haskell exercises I've been solving on my journey learning this language. If you want to check the answers CLICK HERE.
Important note: The solutions work but that doesn't mean they're all the most efficient code you could make. Sometimes I use different ways of solving similar problems so that I can practice different stuff.
NOTE: ºF = ºC x 1.8 + 32
2. Create the necessary functions to make a simple calculator: Addiction, Subtraction, Division and Multiplication
3. A game awards the players a certain amount of money based on their score. Create a function that calculates the amount of money given to the score input.
Score | Prize in $ |
---|---|
1 to 10 | 100 |
10 to 20 | 200 |
20 to 30 | 300 |
30 to 40 | 400 |
40 to 50 | 500 |
More than 50 | 600 |
4. The price of a plane ticket changes based on the age of the traveler. People over the age of 60 pay 60% of the total price. Children younger than 10 years old pay 50% and babies (younger than 2 years old) pay only 10% of the total price of the ticket. Create a function that given the age of the traveler and price of the ticket outputs the price they need to pay.
NOTE: Area = π x r²