-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchap9.hs
27 lines (22 loc) · 823 Bytes
/
chap9.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
module Chap9 where
eftChar :: Char -> Char -> String
eftChar st end
| st == end = []
| (compare st end) == LT = st : eftChar (succ st) end
| otherwise = []
-- same as above but expressed as case expression
eftc2 :: Char -> Char -> String
eftc2 st end = case compare st end of
EQ -> []
LT -> st : eftc2 (succ st) end
uk = putStrLn $ show $ 3 + undefined
getAllWords :: Char -> String -> [String]
getAllWords sep sentence =
let fft = takeWhile (/=sep) sentence
lst = dropWhile (/=sep) sentence
in
case sentence of
"" -> []
(hd : rest)
| hd == sep -> getAllWords sep rest
| otherwise -> fft : getAllWords sep lst