[Haskell-beginners] Re: shortening code

Christian Maeder Christian.Maeder at dfki.de
Wed Jun 30 12:05:44 EDT 2010


Felipe Lessa schrieb:
>  main = interact $ unlines . map (show . (2^) . length . filter
> (`elem` "TDLF")) . lines
> 
> That's 70 non-whitespace characters.  This one-liner is pretty
> readable, probably more than the Perl one ;D.

May I toss in:

main = getLine >>= print . (2 ^) . length . filter (`elem` "TDLF")
  >> main

(60 non-whitespace characters)

C.


More information about the Beginners mailing list