The Erlang shell is used for testing of expressions. Hence, testing can be carried out in the shell very easily before it actually gets tested in the application itself.
The following example showcases how the addition expression can be used in the shell. What needs to be noted here is that the expression needs to end with the dot (.) delimiter.
After the command is executed, the shell prints out another prompt, this time for Command Number 2 (because the command number increases each time a new command is entered).
The following functions are the most common oneβs used in the Erlang shell.
- b() β Prints the current variable bindings.
- Syntax β b().
- For example β Following is an example of how the function is used. First a variable called Str is defined, which has the value abcd. Then b() is used to display all the binded variables.
- f() β Removes all current variable bindings.
- Syntax β f().
- For example β Following is an example of how the function is used. First a variable called Str is defined which has the value abcd. The f() is then used to remove the Str variable binding. The b() is then called to ensure the binding has been successfully removed.
- f(x) β Removes the binding for a particular variable.
- Syntax β f(x). Where, x β is the variable for which the binding needs to be removed.
- For example β Following is an example of how the function is used. First a variable called Str and Str1 are defined. The f(Str) is then used to remove the Str variable binding. The b() is then called to ensure the binding has been successfully removed.
- h() β Prints the history list of all the commands executed in the shell.
- Syntax β h().
- For example β An example of the h() command, which prints the history of commands executed in the shell is shown in the following screenshot.
- history(N) β Sets the number of previous commands to keep in the history list to N. The previous number is returned. The default number is 20.
- Syntax β history(N). Where, N β is the number to which the command history list needs to be limited to.
- For example β An example of the history(N) command is shown in the following screenshot.
- e(N) β Repeats the command N, if N is positive. If it is negative, the Nth previous command is repeated (i.e., e(-1) repeats the previous command).
- Syntax β e(N). Where, N β is the command at the Nth position in the list.
- For example β An example of the e(N) command is shown below. Since we have executed the e(-1) command, it will execute the previous command which was history(5).
Next Topic : Click Here
Pingback: Erlang - Basic Syntax | Adglob Infosystem Pvt Ltd
Thanks-a-mundo for the blog.Really looking forward to read more. Great.