Stack (ExExample v0.1.2)

View Source

I am an example implementation of a Stack. I am used to show example.. examples.

Summary

Types

t()

I represent the key for an example invocation.

Types

t()

@type t() :: %Stack{elements: [any()]}

I represent the key for an example invocation.

Functions

create(xs \\ [])

@spec create([any()]) :: {:ok, t()}

empty?(stack)

@spec empty?(t()) :: boolean()

peek(stack)

@spec peek(t()) :: {:ok, t(), any()} | {:error, :empty}

pop(stack)

@spec pop(t()) :: {:ok, t(), any()} | {:error, :empty}

push(stack, x)

@spec push(t(), any()) :: {:ok, t()}