Created
May 23, 2014 12:49
-
-
Save wunki/13535b7f02993c65732d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module Main where | |
import System.Environment (getArgs) | |
import qualified Data.ByteString.Lazy as L | |
import Data.Word | |
addBytes :: [Word8] -> Word8 | |
addBytes [] = 0 | |
addBytes (x:xs) = x + addBytes xs | |
addBytes' :: [Word8] -> Word8 | |
addBytes' = foldr (+) 0 | |
addBytes'' :: [Word8] -> Word8 | |
addBytes'' = sum | |
main :: IO () | |
main = do | |
args <- getArgs | |
let filename = head args | |
fc <- L.readFile filename | |
print $ addBytes'' $ L.unpack fc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment