-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask03.hs
More file actions
59 lines (40 loc) · 1.48 KB
/
Task03.hs
File metadata and controls
59 lines (40 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
module Task03 where
--Задание №3
type OatmealTemp = Int -- OatmealTemp is in Int[0, 20)
-- intetrp. possible oatmeal temperatures
--1)A
coldTemperature :: OatmealTemp
coldTemperature = 0
perfectTemperature :: OatmealTemp
perfectTemperature = 10
hotTemperature :: OatmealTemp
hotTemperature = 19
fnForOatmealTemperature :: OatmealTemp -> a
fnForOatmealTemperature t = (undefined t)
--1)B
data Adjustment = LeftAdjustment | RightAdjustment | StayAdjustment deriving (Show, Eq, Ord)
-- intetrp. state of stove
fnForStoveAdjustment :: Adjustment -> a
fnForStoveAdjustment ad = case ad of
LeftAdjustment -> undefined
RightAdjustment -> undefined
StayAdjustment -> undefined
--1)C
oatmealTempToAdjustment :: OatmealTemp -> Adjustment
oatmealTempToAdjustment 0 = RightAdjustment
oatmealTempToAdjustment 10 = StayAdjustment
oatmealTempToAdjustment 19 = LeftAdjustment
--2)A
data DinnerOrder = Chicken | Pasta | Nothink deriving (Show, Eq, Ord)
-- intetrp. dinner oreder for YesItCanFly! airlines passangers
fnForDinnerOrder :: DinnerOrder -> a
fnForDinnerOrder ad = case ad of
Chicken -> undefined
Pasta -> undefined
Nothink -> undefined
flightAttendantSpeech :: String -> String
flightAttendantSpeech msg = "The passenger ordered " ++ msg
dinnerOrderToMsg :: DinnerOrder -> String
dinnerOrderToMsg Chicken = flightAttendantSpeech("Chicken")
dinnerOrderToMsg Pasta = flightAttendantSpeech("Pasta")
--dinnerOrderToMsg Nothink = flightAttendantSpeech("Nothink")