Home > Archive > Functional > September 2006 > what does the erlang -Compiling your first program - example explain
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
what does the erlang -Compiling your first program - example explain
|
|
| geletine 2006-08-22, 7:00 pm |
| I cannot see any explanation do the example on
http://www.erlang.org/faq/quick_start.html
-module(test).
-export([fac/1]).
fac(0) -> 1;
fac(N) -> N * fac(N-1)
sorry if this question sounds ignorant
thanks
| |
|
| In article <1156285148.797113.60240@i42g2000cwa.googlegroups.com>,
geletine <adaviscg1@hotmail.com> wrote
>I cannot see any explanation do the example on
>http://www.erlang.org/faq/quick_start.html
>
>-module(test).
>-export([fac/1]).
>
>fac(0) -> 1;
>fac(N) -> N * fac(N-1)
>
>
>sorry if this question sounds ignorant
Try the tutorial. Look at:
http://www.erlang.org/doc/doc-5.5/d...part_frame.html
Section 2.2, "Modules and Functions"
(I personally can't learn anything "off the web"; reading a well
chosen book is infinitely better.)
With kind regards,
Sandy
--
Alexander Anderson <junk.rubbish@alma-services.abel.co.uk>
(Yorkshire, England)
Where there is no vision, the people perish.
| |
| Heri Tamas 2006-08-25, 4:00 am |
| Hi!
I'm also a beginner, but I feel I can help. See my comments
line-by-line bellow.
geletine wrote:
> I cannot see any explanation do the example on
> http://www.erlang.org/faq/quick_start.html
>
> -module(test).
introduces a module named test
> -export([fac/1]).
the module will have an exported function ("fac") with one argument
("/1")
>
> fac(0) -> 1;
the value of the "fac" function is 1 when the argument is 0
> fac(N) -> N * fac(N-1)
the value of "fac" is N * fac(N-1) othwerwise.
There is no if/else control structure here. Simply the fac definition
has more lines,
and the first that matches the argument will be evaluated.
>=20
>=20
> sorry if this question sounds ignorant
>=20
> thanks
Tam=E1s
| |
| geletine 2006-09-02, 6:59 pm |
|
Heri Tamas wrote:
> Hi!
>
> I'm also a beginner, but I feel I can help. See my comments
> line-by-line bellow.
>
> geletine wrote:
> introduces a module named test
> the module will have an exported function ("fac") with one argument
> ("/1")
> the value of the "fac" function is 1 when the argument is 0
> the value of "fac" is N * fac(N-1) othwerwise.
> There is no if/else control structure here. Simply the fac definition
> has more lines,
> and the first that matches the argument will be evaluated.
>=20
> Tam=E1s
thanks both of you , i have a clearer understanding :)
|
|
|
|
|