Skip to content

Instantly share code, notes, and snippets.

@Syzygies
Created October 28, 2012 18:17
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 Syzygies/3969348 to your computer and use it in GitHub Desktop.
Save Syzygies/3969348 to your computer and use it in GitHub Desktop.
module Main where
import Data.Word8 (Word8, _cr, _space, _tab, isAsciiLower)
import qualified Data.ByteString as B
isSpace ∷ Word8 → Bool
isSpace w = w == _space || w <= _cr && w >= _tab
toUpper ∷ Word8 → Word8
toUpper w = if isAsciiLower w then w - _space else w
op ∷ Bool → Word8 → (Bool, Word8)
op flag c = if isSpace c then (True,c) else (False,d)
where d = if flag then toUpper c else c
main ∷ IO ()
main = B.readFile "input.txt" >>= B.putStr . snd . B.mapAccumL op True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment