-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFirstScript.hs
More file actions
43 lines (27 loc) · 834 Bytes
/
FirstScript.hs
File metadata and controls
43 lines (27 loc) · 834 Bytes
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
{- #########################################################
FirstScript.hs
Simon Thompson, August 2010.
######################################################### -}
module FirstScript where
-- The value size is an integer (Integer), defined to be
-- the sum of twelve and thirteen.
size :: Integer
size = 12+13
-- The function to square an integer.
square :: Integer -> Integer
square n = n*n
-- The function to double an integer.
double :: Integer -> Integer
double n = 2*n
-- An example using double, square and size.
example :: Integer
example = double (size - square (2+2)) -- 18
-- Task 4 from page 33
task4a :: Integer -> Integer
task4a n = square (double n)
task4b :: Integer -> Integer
task4b n = double (square n)
a :: Integer
a = 23
fac 0 = 1
fac n = n * fac (n-1)