Mix.install([
{:jason, "~> 1.4"},
{:kino, "~> 0.9", override: true},
{:youtube, github: "brooklinjazz/youtube"},
{:hidden_cell, github: "brooklinjazz/hidden_cell"}
])
Ensure you type the ea
keyboard shortcut to evaluate all Elixir cells before starting. Alternatively, you can evaluate the Elixir cells as you read.
Atoms in Elixir are also used to provide access to Erlang tools. If you're not already familiar, Erlang is the low level language that Elixir is built on. It contains a collection of useful tools
For example, there is the :math
module, which has math related functionality.
Here's how you can get pi from the :math module.
:math.pi()
You will learn more about how to use Erlang through atoms in future lessons. It's enough for now to be aware that Erlang tools can be accessed through certain atoms.
In the Elixir cell below, create an atom of your favorite element. Mine is :hydrogen
because it likes to get along with everyone.
You can find the full list of elements here.
file_name = Path.basename(Regex.replace(~r/#.+/, __ENV__.file, ""), ".livemd")
progress_path = __DIR__ <> "/../progress.json"
existing_progress = File.read!(progress_path) |> Jason.decode!()
default = Map.get(existing_progress, file_name, false)
form =
Kino.Control.form(
[
completed: input = Kino.Input.checkbox("Mark As Completed", default: default)
],
report_changes: true
)
Task.async(fn ->
for %{data: %{completed: completed}} <- Kino.Control.stream(form) do
File.write!(progress_path, Jason.encode!(Map.put(existing_progress, file_name, completed)))
end
end)
form
Run the following in your command line from the curriculum folder to track and save your progress in a Git commit.
Ensure that you do not already have undesired or unrelated changes by running git status
or by checking the source control tab in Visual Studio Code.
$ git checkout solutions
$ git checkout -b erlang-atoms-reading
$ git add .
$ git commit -m "finish erlang atoms reading"
$ git push origin erlang-atoms-reading
Create a pull request from your erlang-atoms-reading
branch to your solutions
branch.
Please do not create a pull request to the DockYard Academy repository as this will spam our PR tracker.
DockYard Academy Students Only:
Notify your instructor by including @BrooklinJazz
in your PR description to get feedback.
You (or your instructor) may merge your PR into your solutions branch after review.
If you are interested in joining the next academy cohort, sign up here to receive more news when it is available.