Given the following erlang
function
-module(fibonacci).
-export([my_function_3/1]).
my_function_3(Arg1) when Arg1==3 -> io:format("=3");
my_function_3(Arg1) when Arg1<3 -> io:format("<3");
my_function_3(Arg1) when Arg1>3 -> io:format(">3").
Calling the my_function_3
function from the command line shows different values than when calling it from the shell (see below).
Please note that I used 2
, 3
and 4
as parameters in order to make the function be evaluated in all its definitions.
Calling the my_function_3
from the erlang
shell
$ erl
Erlang/OTP 22 [erts-10.6.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]
Eshell V10.6.2 (abort with ^G)
1> c(fibonacci).
{ok,fibonacci}
2> fibonacci:my_function_3(2).
<3ok
3> fibonacci:my_function_3(3).
=3ok
4> fibonacci:my_function_3(4).
>3ok
Calling the my_function_3
from the command-line
$ erlc fibonacci.erl
$ erl -noshell -s fibonacci my_function_3 2 -s init stop
>3%
$ erl -noshell -s fibonacci my_function_3 3 -s init stop
>3%
$ erl -noshell -s fibonacci my_function_3 4 -s init stop
>3%
Therefore, my question is: Why does erlang
output different values when calling the function from the command-line and when calling it from the erlang
shell?