-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMain.hs
50 lines (35 loc) · 1.04 KB
/
Main.hs
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
-- option 1 (https://github.com/PiotrJustyna/haskell-anywhere):
-- ./ghci.bat C:\Users\piotr_justyna\Documents\github\programming-in-haskell\part1_chapter3_exercise2
-- option 2 (stack):
-- stack ghci
-- option 3 (ghci):
-- ghci
--
-- :load Main
main = do
putStrLn "bools"
putStrLn . show $ bools
putStrLn "nums"
putStrLn . show $ nums
putStrLn "add 1 2 3"
putStrLn . show $ add 1 2 3
putStrLn "copy \"z\""
putStrLn . show $ copy "z"
putStrLn "apply (+2) 3"
putStrLn . show $ apply (+2) 3
----------------------------------------
bools :: [Bool]
bools = [True, False]
----------------------------------------
nums :: [[Int]]
nums = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
----------------------------------------
add :: Int -> Int -> Int -> Int
add x y z = x + y + z
----------------------------------------
copy :: a -> (a,a)
copy x = (x, x)
----------------------------------------
apply :: (a -> b) -> a -> b
apply f x = f x
----------------------------------------