Haskell, 133
import System.Environment
main=getArgs>>=mapM_(>>=putStr.map l).f
f[]=[getContents]
f n=map readFile n
l x=[x..]!!sum[32|x>'@',x<'[']
The cat-style args processing is derived from this tutorial, then rearranged to shave characters.
Explaining l
, the function to lowercase one character:
sum[32|condition]
is a shorter form ofif condition then 32 else 0
.[x..]!!count
isiterate succ x !! count
istoEnum $ fromEnum x + count
and shorter than importing and usingData.Char.toLower
with a condition to restrict it to ASCII.'@'
and'['
are the characters immediately precedingA
and followingZ
, so that I can use<
instead of<=
.
Thanks to Anders Kaseorg for contributing the sum[...|...]
and [x..]!!
tricks.