diff options
| author | pb <pb@9f8f72e9-4bf4-416e-b76e-7d4203597157> | 2009-12-17 01:59:05 +0000 |
|---|---|---|
| committer | pb <pb@9f8f72e9-4bf4-416e-b76e-7d4203597157> | 2009-12-17 01:59:05 +0000 |
| commit | 22b946cf3885885e42e1cb510bd58232377a5c6f (patch) | |
| tree | 589d6d0f4be61dd38a9b5cdf2bf968ed2b968921 | |
| parent | 1af661dd41a6cd0a16d9bb3556827eb5128fb667 (diff) | |
git-svn-id: https://ssl.buetow.org/repos/hsbot/trunk@13 9f8f72e9-4bf4-416e-b76e-7d4203597157
| -rw-r--r-- | HsBot.hs | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -122,11 +122,23 @@ userKarma user = userKarma' (userPts user) (userPerc user) where userKarma' pts perc = let cands = sort $ filter (\x -> minPts x <= pts && minPerc x <= perc) (karmas makeConf) in karmaName $ cands !! 0 -- Best posible karma - + +-- Sorts a list sort :: (Ord a) => [a] -> [a] sort [] = [] sort (x:xs) = sort (filter (>= x) xs) ++ [x] ++ sort (filter (< x) xs) +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 @@ -136,7 +148,7 @@ split (c:cs) delim -- Returns a list of all strings to increase or decrease the karma of matches :: String -> String -> [String] -matches search string = +matches search string = uniq $ case m' $ occ search string of (list, "") -> list (list, rest) -> list ++ (matches search rest) |
