[erlang-questions] newbie needing help getting started

Joe Armstrong <>
Sat Oct 10 21:59:19 CEST 2009


I'm puzzled by your questions - you souldn't be having these kind of problems.

You say "I'm following THE tutorial" - but there are several - which
tutorial are you following?

There are several tutorials on the net  - if you type in
*exactly* what they say from the beginning you shouldn't have the kind
of problems
you are running into. It would be helpful to know which so the author can
fix the text to prevent the kind of problem you are experiencing.

Two good places to start are

http://www.erlang.org/download/getting_started-5.4.pdf
http://learnyousomeerlang.com/starting-out#the-shell

It's important not to "jump in at the middle" - because the stuff like
"end every command
with dot whitespace" is usually explained near the start of the
tutorial and is easily
missed.

Have fun and don't give up quietly if you get stuck - ask the list!

/Joe



On Sat, Oct 10, 2009 at 3:57 PM, 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