3 ms·
Agreed. As Haskell is the only language among the three that I know well, I had to say it was pretty strange looking. The "length w where w = ..." was especia
by jrockway 17y ago
Agreed. As Haskell is the only language among the three that I know well, I had to say it was pretty strange looking. The "length w where w = ..." was especially strange. Why not, you know, just apply "length" to that expression? That's what functions do :)
I won't comment on the single-expression do block or all the parens in the putStrLn expression or mention that "putStrLn . show" is just "print".
Anyway, 6 lines of Haskell is just excessive. How about two lines:
fibs = 1 : 1 : (zipWith (+) fibs $ tail fibs)
main = print . length . takeWhile (< 10^999) $ fibs
I think this is as readable as the example, and I didn't even have to line-break any expression.
- jules 17y agoHere's some Ruby golf: n,a,b = 1,0,1 n,a,b = n+1,b,a+b while b<10**999 p n 48 chars.