the beginner

Matthias Lang matthias@REDACTED
Wed Apr 30 20:55:47 CEST 2003

wicaksono  writes:

 > my file math1.erl as Wiliam Dominic writen. 
 > -module(math1).
 > -export([factorial/1]).
 > factorial (0) ->1;
 > factorial (N) -> N * factorial (N-1).
 > one that make me confused, the error point to line 8 but 
 > it only has 4 line :(
 > I have tried to compile with so many formats ( in space 
 > format), but  it still didn't work.

I suspect the file you're compiling is not the one you've shown
above. Perhaps you're starting the compiler in a different directory
to where the file is.

Here's what happens on my system:

    matthias >cat math1.erl
    factorial (0) ->1;
    factorial (N) -> N * factorial (N-1).
    matthias >erl
    Erlang (BEAM) emulator version 5.1.1 [source]
    Eshell V5.1.1  (abort with ^G)
    1> c(math1).
    2> math1:factorial(100).

i.e. it works exactly as intended.


More information about the erlang-questions mailing list