Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think Haskell is overall terser than Ruby. The trouble with the accgen test is that it's imperative, and Haskell isn't meant to be. Here's the Haskell implementation that I would submit:

  putStrLn "Don't do that, you nimwit!"


The Erlang version is unnecessarily verbose (and also semantically different) because it uses 2 processes. It can be rewritten as

Foo = fun(N) -> put(var, N), fun(X) -> V = get(var) + X, put(var, V), V end end.

It's not as concise as Ruby or Arc, but it's a one liner. However, similar to Haskell, this style of programming is discouraged in Erlang.


In ML you can get a similar terseness to that of Haskell, but with support for imperative programming. If we allow the increment function to be predefined (as the Arc example does):

 let inc a b = a := !a +/ b; !a
then foo becomes:

 let foo n = inc (ref n)
or, with the help of the composition operator:

 let (<<) f g x = f (g x)

 let foo = inc << ref




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: