stella v0.3.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

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]

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]