blob: bd13271e1dcb9253c9026f9011f69445aee9b3f4 (
plain)
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
|
module HsBot.General.Tools where
uniq :: (Eq a) => [a] -> [a]
uniq list =
let r = u' list 0
u' [] _ = []
u' (x:list) n
| member x r n = u' list n
| otherwise = x:(u' list (n + 1))
member e list 0 = False
member y (x:list) n = x == y || member y list (n - 1)
in r
split :: String -> Char -> [String]
split [] delim = [""]
split (c:cs) delim
| c == delim = "" : rest
| otherwise = (c : head rest) : tail rest
where rest = split cs delim
empty :: String -> Bool
empty str = length str == 0
contains :: String -> Char -> Bool
contains str char = takeWhile (/= char) str /= str
isMultiline :: String -> Bool
isMultiline str = contains str '\n'
showL :: Show a => [a] -> [String]
showL = map (\x -> show x ++ "\n")
|