How to define an function in the eshell (Erlang shell)?
erlang, function
Solution
Yes but it is painful. Below is a "lambda function declaration" (aka `fun` in Erlang terms).
1> F=fun(X) -> X+2 end.
%%⇒ #Fun <erl_eval.6.13229925>
Have a look at this post. You can even enter a module's worth of declaration if you ever needed. In other words, yes you can declare functions.
Problem
Is there any way to define an Erlang function from within the Erlang shell instead of from an erl file (aka a module)?