From de9e80d18816cd11c4b7785e635a3fb0dfe0433a Mon Sep 17 00:00:00 2001 From: pb Date: Sun, 14 Mar 2010 11:52:41 +0000 Subject: modularization git-svn-id: https://ssl.buetow.org/repos/hsbot/trunk@22 9f8f72e9-4bf4-416e-b76e-7d4203597157 --- Tools.hs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Tools.hs (limited to 'Tools.hs') diff --git a/Tools.hs b/Tools.hs new file mode 100644 index 0000000..e28d4f9 --- /dev/null +++ b/Tools.hs @@ -0,0 +1,32 @@ +module 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") + -- cgit v1.2.3