O'Reilly logo

Introducing Elixir by J. David Eisenberg, Simon St. Laurent

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 documents.

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 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 +n+th output value from 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 trying to do if you use certain keywords as function names ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required