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

raocheng rc.china@REDACTED
Sat Sep 29 13:27:30 CEST 2007


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070929/b878a61b/attachment.htm>


More information about the erlang-questions mailing list