Created
November 10, 2009 14:11
-
-
Save maoe/230903 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List (foldl') | |
import Data.Map (Map) | |
import qualified Data.Map as M | |
import System.Environment | |
type Log = String | |
type IPAddr = String | |
type Frequency = Int | |
pageViews :: Integer -> Log -> Integer | |
pageViews = undefined | |
uniqueUsers :: Integer -> Log -> Integer | |
uniqueUsers = undefined | |
freqentSourceAddrs :: Map IPAddr Frequency -> Log -> Map IPAddr Frequency | |
freqentSourceAddrs = undefined | |
analyze :: [Log] -> (Integer, Integer, Map IPAddr Frequency) | |
analyze = foldl' (\(a1, a2, a3) c -> | |
( pageViews a1 c | |
, uniqueUsers a2 c | |
, freqentSourceAddrs a3 c)) | |
(0, 0, M.empty) | |
main :: IO () | |
main = do | |
(f:_) <- getArgs | |
print . analyze . lines =<< readFile f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment