[erlang-questions] getting started with IO: question about syntax

David Clarke Stevens dcs619@REDACTED
Mon Oct 30 11:19:52 CET 2006


I know this is a typical noob question, but I'm just getting into Erlang and
can't seem to get it working correctly.  I've written a simple factorial
function that I want to display text with, but the compiler complains about
syntax...any help would be appreciated!!

    -module(factorial).
    -export([main/0]).

    main() ->
        io:format("The factorial of 5 is: ").
        fac(5).

    fac(X) ->
        if X == 1 ->
            1;
        else ->
            X * fac(X - 1)
        end.

The compile error I'm getting is:
21> c(factorial).
./factorial.erl:6: syntax error before: '.'
./factorial.erl:8: Warning: function fac/1 is unused
error
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20061030/4afb1e68/attachment.htm>


More information about the erlang-questions mailing list