A language inspired by Ruby and Elixir.
Compiles to BEAM for easy interoperatbility with other BEAM languages (Erlang, Elixir).
module Fibonacci do
fn fib(0) do 0 end
fn fib(1) do 1 end
fn fib(x) do
fib(x - 1) + fib(x - 2)
end
end# Choose one:
sudo apt install elixir # for Debian/Ubuntu
sudo dnf install elixir # for Fedora
sudo zypper install elixir # for SUSE/openSUSERun a file:
$ mix opal examples/the_answer.opal
42Compile a file:
mix opal --compile examples/the_answer.opalRun code directly from Elixir:
$ iex -S mix
iex(1)> Opal.run("fn the_answer_to_everything() do 42 end the_answer_to_everything()")
42MIX_ENV=prod mix do escript.build + escript.installThis will install opal to ~/.mix/escripts/opal. Ensure ~/.mix/escripts is in your $PATH.
To uninstall:
MIX_ENV=prod mix escript.uninstall opalmix test --trace