Haskell, 144133
import System.Environment
main=getArgs>>=mapM_(>>=putStr.map l).f
l x|x>'@'&&x<'['=iterate succ x!!32|0<1=x
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.
iterate succ x!!32
is 2 characters shorter than the non-silly way Explaining toEnum$fromEnum x+32l
, and 1 character shorter than importing and using Data.Char.toLower
with a condition to restrict itthe function to ASCII.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<=
.
'@'
and '['
are Thanks to Anders Kaseorg for contributing the characters immediately preceding Asum[...|...]
and following Z
, so that I can use <
instead of <=[x..]!!
tricks.