[erlang-questions] Can not understand the example.
Torbjorn Tornkvist
tobbe@REDACTED
Fri Jan 19 16:55:33 CET 2007
LUKE wrote:
> -module(tut1).
> -export([fac/1]).
>
> fac(1) ->
> 1;
> fac(N) ->
> N * fac(N - 1).
> ==================================
> How can i know the function will STOP at N=1?
> ===================================
> -module(tut4).
>
> -export([list_length/1]).
>
> list_length([]) ->
> 0;
> list_length([First | Rest]) ->
> 1 + list_length(Rest).
> ===================================
> How can i know the loop will stop when First=[ ]?
> ===================================
> How to explain theses code?
>
> In perl:
> for (my $i=0;$i<=10;$i++){
> ....
> }
>
> It is very clear the process will stop when $i > 10.
>
Ha ha...thank god its Friday :-)
--Tobbe
More information about the erlang-questions
mailing list