stella v0.4.0 Stack
Documentation for Stack
data structure
Link to this section Summary
Functions
Check if stack is empty
Create new, empty stack
Delete top element of stack
Add new element on the top of stack
Link to this section Functions
Link to this function
is_empty(stack)
Check if stack is empty
Examples
iex> Stack.is_empty([])
true
Link to this function
new()
Create new, empty stack
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)
Delete top element of stack
Examples
iex> Stack.pop([])
[]
iex> Stack.pop([1])
[]
Link to this function
push(stack, element)
Add new element on the top of stack
Examples
iex> Stack.push([], 1)
[1]
iex> Stack.push([1, 2], 3)
[1, 2, 3]
iex> Stack.push([1, 2], [3, 4, 5])
[1, 2, 3, 4, 5]