Skip to content

Instantly share code, notes, and snippets.

@wunki
Created May 23, 2014 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wunki/13535b7f02993c65732d to your computer and use it in GitHub Desktop.
Save wunki/13535b7f02993c65732d to your computer and use it in GitHub Desktop.
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