Stack (stella v0.7.0)
Documentation for Stack
data structure
Link to this section Summary
Functions
Checks if stack is empty
Creates new, empty stack
Deletes the top element of the stack
Adds a new element to the top of the stack
Link to this section Functions
Link to this function
is_empty(stack)
Checks if stack is empty
examples
Examples
iex> Stack.is_empty([])
true
iex> Stack.is_empty(["5", 3, 4])
false
Link to this function
new()
@spec new() :: []
Creates new, empty stack
examples
Examples
iex> Stack.new()
[]
iex> Stack.new() |> Stack.push([1, 2, 3])
[1, 2, 3]
iex> Stack.new() |> Stack.push([1, 2, 3, 4]) |> Stack.pop()
[1, 2, 3]
Link to this function
pop(stack)
Deletes the top element of the stack
examples
Examples
iex> Stack.pop([])
[]
iex> Stack.pop([1])
[]
Link to this function
push(stack, element)
Adds a new element to the top of the stack
examples
Examples
iex> Stack.push([], 1)
[1]
iex> Stack.push([1, 2], 3)
[1, 2, 3]
iex> Stack.push([1, 2, :xxx], [3, 4, 0.001, 5, "5"])
[1, 2, :xxx, 3, 4, 0.001, 5, "5"]