News for hackers. Stuff that matters.
Re:In Praise of Haskell by nahiluhmot on Monday November 04, 2013 @12:35PM (#6669892)
It wasn't so much a bad example so much as it was a trivial one. Perhaps a more powerful one (that displays the advantages of lazy evaluation and higher-order functions) would be the function to generate an infinite list of Fibonacci numbers.

    fibs :: [Integer]
    fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
Even still, it's difficult to get the feel of actually using the language from one function taken from a freshman year CS class.
Re:In Praise of Haskell by cgh on Monday November 04, 2013 @01:08PM (#6670099)
How about demonstrating the power of laziness by generating the power set of a set? (Taken from Learn You a Haskell).

  powerset :: [a] -> [[a]]  
  powerset xs = filterM (\x -> [True, False]) xs  

  ghci> powerset [1,2,3]  
  [[1,2,3],[1,2],[1,3],[1],[2,3],[2],[3],[]]
Edit: I read LYaH some time ago but this example stuck with me because it's both wonderful and mind-blowing.
Re:In Praise of Haskell by platz on Thursday November 07, 2013 @11:56PM (#6694532)
Here's a recursive definition which is less cool but less 'magic'

    powerset        :: [a] -> [[a]]
    powerset     [] =  [[]]
    powerset (x:xs) =  yss ++ map (x:) yss
                       where yss = powerset xs

    > powerset [1,2,3]
 
    [[],[3],[2],[2,3],[1],[1,3],[1,2],[1,2,3]]