English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Erlang Shell

The Erlang Shell is used to test expressions. Therefore, before testing in the application itself, it can be tested very easily in the shell.

The following example demonstrates how to use arithmetic expressions in the shell. It should be noted that the expression needs to end with a dot (.) separator.

After the command is executed, the shell will print out another prompt, this time for Command Number 2(Because every time a new command is entered, the command count increases).

The following functions are the most commonly used functions in the Erlang Shell.

  • b() −Print the current variable bindings.

  • syntax - b()

  • For example−Here is an example of how to use this feature. First, define a variable namedStrThe variable, whose value isabcdThenb()Used to display all bound variables.

  • f() −Unbind all current variable bindings.

  • syntax - f().

  • For example−Here is an example of how to use the function. First, define a variable named Str with the value abcd. Then use f() to unbind the Str variable. Then call b() to ensure that the binding has been successfully removed.

  • f(x) −Unbind the binding of a specific variable.

  • syntax- f(x). Where, x is the variable that needs to be unbound.

  • For example−The following is an example of how to use a function. First, define a named Str and Str1variables. Then use f(Str) to delete the variable binding of Str. Then call b() to ensure that the binding has been successfully deleted

  • h() −Prints the list of all commands executed in the shell.

  • syntax- h().

  • Example −The following screen shot shows an example of the h () command, which prints the history of commands executed in the shell.

  • history(N)−Sets the number of previous commands retained in the history list to N. Returns the number of previous commands. The default value is20.

  • syntax- history(N). Where, N – is the number of command history list to be limited.

  • For example−The following screen shot shows an example of the history(N) command.

  • e(N)−If N is positive, repeat the command N times. If negative, repeattheNnumberthe previous command (i.e., e(-1) to repeat the previous command).

  • syntax- e(N). Where, N – is the position of the listtheNnumbercommand at the position.

  • For example−e(N) command examples are as follows. Since we have already executed e(-1) command, it will execute the previous command, that is, history(5)。