Hacking with the Erlang Emulator

The  erl program starts an Erlang runtime system. The exact details
(for example, whether erl is a script or a program and which other
programs it calls) are system-dependent.





commandline session


$erl
Erlang R15B01 (erts-5.9.1)  [64-bit] [async-threads:0] [kernel-poll:false]

Eshell V5.9.1 (abort with ^G)
1> b().
ok
2> double = fun(value) -> 2*value end.
** exception error: no match of right hand side value #Fun<erl_eval.6.82930912>
3> double = fun(value) -> ( 2 * value) end.
** exception error: no match of right hand side value #Fun<erl_eval.6.82930912>
4> double = fun(value) -> 2 * value end.
** exception error: no match of right hand side value #Fun<erl_eval.6.82930912>
5> Double = fun(value) -> 2 * value end.
#Fun<erl_eval.6.82930912>
6> Double(5).
** exception error: no function clause matching
erl_eval:'-inside-an-interpreted-fun-'(5)
7> b().
Double =
fun(value) ->
2 * value
end
ok
8> Double(5).
** exception error: no function clause matching
erl_eval:'-inside-an-interpreted-fun-'(5)
9> Double = fun(Value) -> (2 * Value) end.
** exception error: no match of right hand side value #Fun<erl_eval.6.82930912>
10> Double = fun(Value) -> 2 * Value end.
** exception error: no match of right hand side value #Fun<erl_eval.6.82930912>
11> Double = fun(Value) -> 2*Value end.
** exception error: no match of right hand side value #Fun<erl_eval.6.82930912>
12> Double = fun(Value) -> 2*Value end.
** exception error: no match of right hand side value #Fun<erl_eval.6.82930912>
13> Double = fun(value) -> 2*value end.
#Fun<erl_eval.6.82930912>
14> b().
Double =
fun(value) ->
2 * value
end
ok
15> Double(5).
** exception error: no function clause matching
erl_eval:'-inside-an-interpreted-fun-'(5)
16> Double(2).
** exception error: no function clause matching
erl_eval:'-inside-an-interpreted-fun-'(2)
17> value = 10
17> Double(value).
* 2: syntax error before: Double
17> Double = fun(value) -> 2 * value end.
#Fun<erl_eval.6.82930912>
18> Double(value).
** exception error: bad argument in an arithmetic expression
in operator */2
called as 2 * value
19> Double = fun(value) -> 2 + value end.
** exception error: no match of right hand side value #Fun<erl_eval.6.82930912>
20> Double = fun(value) -> 2+value end.
** exception error: no match of right hand side value #Fun<erl_eval.6.82930912>
21> Double = fun(value) -> (2 + value) end.
** exception error: no match of right hand side value #Fun<erl_eval.6.82930912>
22> Double = fun(value) -> value end.
** exception error: no match of right hand side value #Fun<erl_eval.6.82930912>
23> Double = fun(value) -> value+1 end.
** exception error: no match of right hand side value #Fun<erl_eval.6.82930912>
24> Double1 = fun(value) -> value+1 end.
#Fun<erl_eval.6.82930912>
25> Double1(value).
** exception error: bad argument in an arithmetic expression
in operator +/2
called as value + 1
26> Double1(3).
** exception error: no function clause matching
erl_eval:'-inside-an-interpreted-fun-'(3)
27> summer = fun(Val) -> Val + 1 end.
** exception error: no match of right hand side value #Fun<erl_eval.6.82930912>
28> Summer = fun(Val) -> Val + 1 end.
#Fun<erl_eval.6.82930912>
29> Summer(2).
3
30>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s