Erlang: beginning

So, now Erlang language. The first impression is good. Very good:
fib(0) -> 0;
fib(1) -> 1;
fib(N) when N > 0 -> fib(N - 1) + fib(N - 2).
lists:foreach(fun(N) -> io:format("n=~p => ~p~n", [N, fib(N)]) end, lists:seq(0, 39)).
view raw gistfile1.erl hosted with ❤ by GitHub

Compare this with other languages. It took 17 seconds to complete (as twice as longer than C# version, but three times faster than Ruby). Interestingly than all four cores of the CPU was loaded for 25% during the test.

Comments

Popular posts from this blog

Regular expressions: Rust vs F# vs Scala

Hash maps: Rust, F#, D, Go, Scala

Haskell: performance