Noether (noether v0.2.3)

Noether aims to ease common data manipulation tasks by introducing simple algebraic functions and other utilities. Functions and names are inspired (sometimes taken as-is) from Haskell.

The Noether.Maybe module introduces operations on nullable values.
The Noether.Either module introduces operations on {:ok, _} | {:error, _} values.
The Noether.List module introduces operations on lists.

The root module has a few simple functions one might find of use.

Link to this section Summary

Functions

Takes a tuple and a function of arity 2. It applies the two values in the tuple to the function.

Takes a function of arity 2 and returns the same function with its arguments in reverse order, i.e., "flipped". Please note that if a function of different arity is given, a function of arity 2 is returned where the two arguments will be applied to the given function.

Takes two values and applies them to a function or arity 1 in form of a tuple.

Link to this section Types

@type fun1() :: (any() -> any())
@type fun2() :: (any(), any() -> any())

Link to this section Functions

@spec curry(tuple(), fun2()) :: any()

Takes a tuple and a function of arity 2. It applies the two values in the tuple to the function.

examples

Examples

iex> curry({1, 2}, &Kernel.+/2)
3
@spec flip(fun2()) :: fun2()

Takes a function of arity 2 and returns the same function with its arguments in reverse order, i.e., "flipped". Please note that if a function of different arity is given, a function of arity 2 is returned where the two arguments will be applied to the given function.

examples

Examples

iex> flip(&Kernel.-/2).(3, 4)
1
Link to this function

uncurry(a, b, f)

@spec uncurry(any(), any(), fun1()) :: any()

Takes two values and applies them to a function or arity 1 in form of a tuple.

examples

Examples

iex> uncurry(1, 2, &(&1))
{1, 2}