Quark v1.0.1 Quark.SKI

The classic SKI system combinators. s and k alone can be used to express any algorithm, though generally not efficiently.

Summary

Functions

i()

The identity combinator

k()

The constant (“Konstant”) combinator. Returns the first argument, unchanged, and discards the second argument. Can be used to repeatedly apply the same value in functions such as folds

s()

The “substitution” combinator. Applies the last argument to the first two, and then the first two to each other

Functions

i()

The identity combinator


iex> i(1)
1

iex> i("identity combinator")
"identity combinator"
i(x)

Specs

i(any) :: any
k()

The constant (“Konstant”) combinator. Returns the first argument, unchanged, and discards the second argument. Can be used to repeatedly apply the same value in functions such as folds.


iex> k(1, 2)
1

iex> k("happy", "sad")
"happy"

iex> Enum.reduce([1,2,3], [42], &k/2)
3
k(x)
k(x, y)

Specs

k(any, any) :: any
s()

The “substitution” combinator. Applies the last argument to the first two, and then the first two to each other.


iex> add = &(&1 + &2)
iex> double = &(&1 * 2)
iex> s(add, double, 8)
24
s(x)
s(x, y)
s(x, y, z)

Specs

s((... -> any), (... -> any), any) :: any