Stack
Mix.install([
{:kino, github: "livebook-dev/kino", override: true},
{:kino_lab, "~> 0.1.0-dev", github: "jonatanklosko/kino_lab"},
{:vega_lite, "~> 0.1.4"},
{:kino_vega_lite, "~> 0.1.1"},
{:benchee, "~> 0.1"},
{:ecto, "~> 3.7"},
{:math, "~> 0.7.0"},
{:faker, "~> 0.17.0"},
{:utils, path: "#{__DIR__}/../utils"},
{:tested_cell, git: "https://github.com/BrooklinJazz/tested_cell"}
])
Navigation
Stack
Test and implement a Stack
process.
The Stack
process should store a list as state and push/2
elements onto the stack, and pop/2
elements
off of the stack like so.
{:ok, pid} = Stack.start_link([])
[:one] = Stack.push(pid, :one)
[:two, :one] = Stack.push(pid, :two)
:two = Stack.pop(pid)
:one = Stack.pop(pid)
# return no value when the stack is empty
nil = Stack.pop(pid)
Implement and test the Stack
module. Ensure you have at least one test each for the push/2
function
and the pop/1
function.
defmodule Stack do
use GenServer
end
defmodule StackTests do
use ExUnit.Case
end
Commit Your Progress
Run the following in your command line from the project folder to track and save your progress in a Git commit.
$ git add .
$ git commit -m "finish stack exercise"