[erlang-questions] newbie needing help getting started

Roberto Aloi <>
Sat Oct 10 19:14:55 CEST 2009


Just use a dot instead of a semicolon at the end of your commands.

Roberto Aloi
http://erlang-consulting.com

On 10 Oct 2009, at 14:57, Juan Backson <> wrote:

> Hi
>
> Thank you so much for your help.  I managed to compile the sample  
> code, but
> I can't run it:
>
> [ erlang]# cat math1.erl
> -module(math1).
> -export([factorial/1]).
> factorial(0) -> 1;
> factorial(N) -> N * factorial(N-1).
>
> [ erlang]# ls
> math1.beam  math1.erl
> [ 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 <>  
> 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 <>
>> 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