-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chapter3.hs
55 lines (49 loc) · 1.15 KB
/
Chapter3.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
51
52
53
54
55
module Chapter3 where
-- pg 106
-- area d = pi * (r * r)
-- r = d / 2
-- pg 109
-- area d = pi * (r * r)
-- where r = d / 2
--
--
-- -- pg 109
-- Prelude> :t (++)
-- (++) :: [a] -> [a] -> [a]
-- Prelude> ++ [1, 2, 3] [4, 5, 6]
--
-- <interactive>:18:1: parse error on input `++'
-- Prelude> [1, 2, 3] ++ [4, 5, 6]
-- [1,2,3,4,5,6]
-- Prelude> (++) [1, 2, 3] [4, 5, 6]
-- [1,2,3,4,5,6]
-- Prelude> :t '<3'
--
-- <interactive>:1:2: parse error on input `<'
-- Prelude> :t "<3"
-- "<3" :: [Char]
-- Prelude> '<3
--
-- <interactive>:23:2: parse error on input `<'
-- Prelude> '<3'
--
-- <interactive>:24:2: parse error on input `<'
-- Prelude> "<3" ++ ' Haskell'
--
-- <interactive>:25:9:
-- Syntax error on 'Haskell'
-- Perhaps you intended to use TemplateHaskell
-- In the Template Haskell quotation 'Haskell'
-- Prelude> "<3" ++ " Haskell"
-- "<3 Haskell"
-- Prelude> concat ["<3", " Haskell"]
-- "<3 Haskell"
-- Prelude> (++) "<3" " Haskell"]
--
-- <interactive>:28:21: parse error on input `]'
-- Prelude> (++) "<3" " Haskell"
-- "<3 Haskell"
-- pg 115
take ((length "awesome!") -1) "awesome!"
take 7 "awesome!"
head (drop 4 n)