diff options
| author | pb <pb@9f8f72e9-4bf4-416e-b76e-7d4203597157> | 2010-03-28 10:42:32 +0000 |
|---|---|---|
| committer | pb <pb@9f8f72e9-4bf4-416e-b76e-7d4203597157> | 2010-03-28 10:42:32 +0000 |
| commit | 3911a1935535df6d65694339e7f7140714379b56 (patch) | |
| tree | 2f558d279e8ded4f35ea2de7016323845615f252 /HsBot/Tools.hs | |
| parent | 561aa6d45ed2c7dc6cd177bab5c31f6d8fccde66 (diff) | |
git-svn-id: https://ssl.buetow.org/repos/hsbot/trunk@45 9f8f72e9-4bf4-416e-b76e-7d4203597157
Diffstat (limited to 'HsBot/Tools.hs')
| -rw-r--r-- | HsBot/Tools.hs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/HsBot/Tools.hs b/HsBot/Tools.hs new file mode 100644 index 0000000..6f66994 --- /dev/null +++ b/HsBot/Tools.hs @@ -0,0 +1,32 @@ +module HsBot.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") + |
