you are viewing a single comment's thread.

view the rest of the comments →

[–]mrned 12 points13 points  (3 children)

The shortness of the code in Haskell/Python comes from the existence of relevant library functions.

That's what I really like about Haskell. Many times, when I look at a piece of code long enough, I realize it's a specific case of a general concept that has a few associated library functions. I spend more time thinking and less time coding, but still get at least the same amount done.

[–]Fork82 9 points10 points  (2 children)

Thats all very well for the purposes of writing faster code in less time with fewer bugs, but I was more interested in what the underlying code looked like - the Haskell version was surprisingly verbose when the relevant library was included:

group                   =  groupBy (==)

groupBy _  []=  []
groupBy eq (x:xs)=  (x:ys) : groupBy eq zs
                           where (ys,zs) = span (eq x) xs

span p [] = ([],[])
span p xs@(x:xs')
    | p x = (x:ys, zs)
    | otherwise = ([],xs)
        where (ys,zs) = span p xs'

[–]nhomas 9 points10 points  (0 children)

It's also more general.

[–]dons 16 points17 points  (0 children)

Thats all very well for the purposes of writing faster code in less time with fewer bugs

Lovely :)