-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctionLecture.hs
More file actions
56 lines (38 loc) · 1.19 KB
/
functionLecture.hs
File metadata and controls
56 lines (38 loc) · 1.19 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
module Revision where
isSmall :: Int -> Bool
isSmall x = x<5--no need for if/else for one boolean operator
greet :: String -> String
greet x = "Good Day " ++ x ++ "!"
fiveTimes :: String -> String
fiveTimes s =
s ++ " " ++ s ++ " " ++ s ++ " " ++ s ++ " " ++ s
isLetterZ :: Char -> Bool
isLetterZ c =
c == 'Z'
isLetterZ' :: Char -> Bool
isLetterZ' letter
| letter == 'Z' = True
| letter == 'z' = True
| otherwise = False
rectangleArea :: Int -> Int -> String
rectangleArea x y =
"Area of Rectangle = " ++ show (x*y)
biggerThan :: Int -> Int -> Bool
biggerThan x y = x>y
biggerThan' :: Int -> Int -> String
biggerThan' x y =
if x>y
then show (x) ++ " is bigger than " ++ show (y)
else show (x) ++ " is not bigger than " ++ show (y)
joinStrings :: String -> String -> String -> String
joinStrings x y z =
"Here are your three strings concatenated: " ++ x ++ y ++ z
chooseCoat :: Int -> Int -> String
chooseCoat temp rainfall =
if (temp<10) && (rainfall > 5)
then "Stay The Fuck In!"
else if temp<10
then "Wear a duffle coat"
else if rainfall > 5
then "Rain Mac it is!"
else "summer jacket:-)"