Tuesday, January 15, 2008

Concurrency starts now!

Reached chapter 7 of programming erlang. Concurrency starts now.
Let see how my brain-system handles this :)

Tuesday, January 01, 2008

3 liner list reversal

-module(mylist).
-export([reverse/1]).

reverse(L) -> reverse(L, []).

reverse([H|T], Rl) -> reverse(T, [H|Rl]);
reverse([], Rl) -> Rl.

Thats it!

Here is the usage -
mylist:reverse([0, 1, 2, 3, 4, 5]).

should give -
[5, 4, 3, 2, 1, 0]