From 1af661dd41a6cd0a16d9bb3556827eb5128fb667 Mon Sep 17 00:00:00 2001 From: pb Date: Thu, 17 Dec 2009 00:46:04 +0000 Subject: git-svn-id: https://ssl.buetow.org/repos/hsbot/trunk@12 9f8f72e9-4bf4-416e-b76e-7d4203597157 --- HsBot.hs | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'HsBot.hs') diff --git a/HsBot.hs b/HsBot.hs index 2a835d2..ac6876c 100644 --- a/HsBot.hs +++ b/HsBot.hs @@ -142,29 +142,21 @@ matches search string = (list, rest) -> list ++ (matches search rest) where occ :: String -> String -> Maybe (String, String) occ search str = o' "" search str - where o' pred [] str = - Just (init . init $ reverse pred, str) + where o' pred [] str = Just (init . init $ reverse pred, str) o' pred occ [] = Nothing o' pred (m:occ) (s:str) | m == s = o' (s:pred) occ str | otherwise = o' (s:pred) search str - split' str = map (filter (\x -> (x /= '-') && (x /= '+'))) $ split str ' ' - extrL str - | last str == ' ' = [] - | otherwise = [last $ split' str] - extrR str - | str !! 0 == ' ' = [] - | otherwise = [split' str !! 0] - m' (Just (a, "")) = (extrL a, "") - m' (Just ("", b)) = (extrR b, b) - m' (Just (a, b)) = ((extrL a) ++ (extrR b), b) + extr extrF = extrF . filter (\x -> (x /= '-') && (x /= '+')) + extrL str -- extract left side + | null str || last str == ' ' = [] + | otherwise = [last $ split str ' '] + extrR str -- extract right side + | null str || str !! 0 == ' ' = [] + | otherwise = [split str ' ' !! 0] + m' (Just (a, b)) = ((extr extrL a) ++ (extr extrR b), b) m' Nothing = ([], []) -test1 = matches "++" "++foo" -test2 = matches "++" "foo++" -test3 = matches "++" "++foo++" -test4 = matches "++" "++foo ++bar++ --baz++" - processInput :: Conf -> Conf processInput conf = loggMessage "foo" conf where plus = matches "++" (line conf) -- cgit v1.2.3