Sha256: cc2011fabb5ef51890576c5422d707c55facdc8d17d22446af827696c79832d1
Contents?: true
Size: 1.54 KB
Versions: 284
Compression:
Stored size: 1.54 KB
Contents
defmodule LinkedList do @opaque t :: tuple() @doc """ Construct a new LinkedList """ @spec new() :: t def new() do # Your implementation here... end @doc """ Push an item onto a LinkedList """ @spec push(t, any()) :: t def push(list, elem) do # Your implementation here... end @doc """ Calculate the length of a LinkedList """ @spec length(t) :: non_neg_integer() def length(list) do # Your implementation here... end @doc """ Determine if a LinkedList is empty """ @spec empty?(t) :: boolean() def empty?(list) do # Your implementation here... end @doc """ Get the value of a head of the LinkedList """ @spec peek(t) :: {:ok, any()} | {:error, :empty_list} def peek(list) do # Your implementation here... end @doc """ Get tail of a LinkedList """ @spec tail(t) :: {:ok, t} | {:error, :empty_list} def tail(list) do # Your implementation here... end @doc """ Remove the head from a LinkedList """ @spec pop(t) :: {:ok, any(), t} | {:error, :empty_list} def pop(list) do # Your implementation here... end @doc """ Construct a LinkedList from a stdlib List """ @spec from_list(list()) :: t def from_list(list) do # Your implementation here... end @doc """ Construct a stdlib List LinkedList from a LinkedList """ @spec to_list(t) :: list() def to_list(list) do # Your implementation here... end @doc """ Reverse a LinkedList """ @spec reverse(t) :: t def reverse(list) do # Your implementation here... end end
Version data entries
284 entries across 284 versions & 1 rubygems