[erlang-questions] newbie needing help getting started

Juan Backson juanbackson@REDACTED
Sat Oct 10 15:57:09 CEST 2009


Hi

Thank you so much for your help.  I managed to compile the sample code, but
I can't run it:

[root@REDACTED erlang]# cat math1.erl
-module(math1).
-export([factorial/1]).
factorial(0) -> 1;
factorial(N) -> N * factorial(N-1).

[root@REDACTED erlang]# ls
math1.beam  math1.erl
[root@REDACTED erlang]# erl
Erlang R13B02 (erts-5.7.3) [source] [64-bit] [smp:2:2] [rq:2]
[async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.7.3  (abort with ^G)
1> math1:factorial(0)
1> ;
1> math1:factorial(0);


What am I missing?

jb

On Sat, Oct 10, 2009 at 9:51 PM, Joe Armstrong <erlang@REDACTED> wrote:

> You cannot type -module(math1). directly into the shell.
> make a file (math.erl) containing the lines "-module(math1). ..." etc.
> then compile the module in the shell like this:
>
> > c(math1).
>
> This will compile the code in math1.erl, then you can run the
> functions in the shell
> > math1:funcname(...) etc.
>
> /Joe
>
>
> On Sat, Oct 10, 2009 at 3:45 PM, Juan Backson <juanbackson@REDACTED>
> wrote:
> > Hi,
> >
> > I am following the tutorial trying to get started.  I am getting error
> with
> > the following sample code in ERL command line.
> >
> > 10> -module(math1).
> > ** exception error: undefined shell command module/1
> > 11> -export([factorial/1]).
> > ** exception error: bad argument in an arithmetic expression
> >     in operator  '/'/2
> >        called as factorial / 1
> >
> >
> > Could someone help me out ?  What is wrong ?
> >
> > jb
> >
>


More information about the erlang-questions mailing list