Learning Erlang

要开始高调学习Erlang了,先来报个到!

-module(tut).
-author(ecloud).
-export([fac/1, del/2]).

-include_lib("eunit/include/eunit.hrl").

%% @spec fac(integer()) -> integer().
-spec fac(integer()) -> integer().

fac(0) -> 1;
fac(N) -> N * fac(N-1).

-spec del(any(), list()) -> list().

del(Term, [Term|T] -> T;
del(Term, [H|T]) -> [H|del(Term, T)];
del(_Term, []) -> [].

register(tut, spawn(cp1@uss, fun() -> receive stop -> void end end)).

%% -------------------------------------------------------
%% Test
%% -------------------------------------------------------
fac_test_() -> 
[
    ?_assertEqual(fac(3), 6)
].

几点想起来的原因如次:

  • Erlang能方便地进行应用开发
  • 很好的学习分布式和并行算法的平台
  • VM的实现