[erlang-questions] Example in <<Programming Erlang>>

Anders Nygren anders.nygren@REDACTED
Sat Sep 29 16:32:26 CEST 2007


On 9/29/07, raocheng <rc.china@REDACTED> wrote:
> There is an example in <<Programming Erlang>> (Chapter 6.3):
>
> factorial.erl
>
> #!/usr/bin/env escript
> main([A]) ->
>  I = list_to_integer(A),
>  F = fac(I),
>  io:format("factorial ~w = ~w~n" ,[I, F]).
>  fac(0) -> 1;
>  fac(N) ->
>   N * fac(N-1).
>
>
> However, when I execute this example, it outputs:
> $ ./factorial 25
> escript: script failed with error reason {function_clause,
>                                  [{local,
>                                    main,
>
> [["25","-s","cean","version"]]}]}
>
> What's wrong with me ? Thank you very much.

Hi
It seems like Your CEAN based version of escript add some extra parameters.
I think that if You change to this it will work.

main([A|_]) ->


/Anders



More information about the erlang-questions mailing list