On Mon, Sep 28, 2009 at 11:50 PM, Hong Yang <hyang...@gmail.com> wrote: > learn and use. In my humble opinion, Haskell has a lot of libraries, but > most of them offer few examples of how to use the modules. In this regards, > Perl is much much better.
The Perl call is spot on. Specially because Haskell has been incorporating so much syntatic sugar that it's almost looking Perlish noise already: import Data.Array.Diff import Data.IArray update :: (Char -> [Int]) -> DiffArray Int ModP -> Char -> DiffArray Int ModP update lookup arr c = arr // (map calc . lookup $ c) where calc i = (i, (arr ! i) + (arr ! (i-1))) solve line sol = (foldl' (update lookup) iArray line) ! snd (bounds iArray) where iArray = listArray (0, length sol) $ 1 : map (const 0) sol lookup c = map (+1) . findIndices (== c) $ sol I've not been following Haskell too much and am completely lost when reading code like that. I understand (+1), : and ! but what the hell are . and $ for? And that weird monad symbol in the Haskell logo is not even used! >>= Not quite the worst example of such line noise much of Haskell idiomatic code uses nowadays, though. Point is: >>= . $ : ! `` and meaningful whitespace are all nice shortcuts, but also hairy confusing... _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe