Appendix A. An Elixir Parts Catalog

Like every language, Elixir has drawers full of parts that are fun to peruse, and there are many more available through Erlang.

These are a few of the more common ones, all represented using Elixir calling conventions. If you want (much, much) more, see the Erlang User Guide.

Shell Commands

You can use most Elixir functions from the shell, but the commands shown in Table A-1 are ones that are exclusive to the shell.

Table A-1. Elixir shell commands
Command Action

c(file)

Compiles the specified Erlang file

c(file,path)

Compiles the specified file and puts object code in the directory specified by path

ls()

Lists files at the current location

ls(path)

Lists files at the specified path

cd(directory)

Changes to the specified directory

pwd()

Gets the present working directory

clear()

Clears the screen

h()

Prints list of available helpers

h(item)

Prints help for the specified item

l(module)

Loads the given module’s code, purging the current version

m()

Lists all loaded modules

r(module)

Recompiles and reloads the given module’s source file

v()

Prints a list of all commands and returned values for this session

v(n)

Retrieves the nth output value from the shell session

flush()

Flushes all messages sent to the shell

Reserved Words

There are a few Elixir terms you can’t use outside of their intended context.

The Elixir compiler will wonder what you’re ...

Get Introducing Elixir, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.