Tuesday, May 09, 2006

Counting lines


module Main where

main = print . length . lines =<< getContents


=<< is the sequencing operator being used here in lieu of do. "." is the function composition operator.

This can also be written as:

module Main where

main = do lns <- getContents
let lns' = lines lns
print (length lns')

No comments:

Post a Comment