Erlang: beginning
So, now Erlang language. The first impression is good. Very good:
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)). |
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