Quark v2.2.0 Quark.BCKW

The classic BCKW combinators. A similar idea to SKI, but with different primitives.

Summary

Functions

b()

Normal (binary) function composition

c()

Reverse (first) two arguments (flip). Aliased as flip

w()

Apply the same argument to a functon twice

Functions

b()

Normal (binary) function composition

Examples

iex> sum_plus_one = b(&(&1 + 1), &Enum.sum/1)
iex> [1,2,3] |> sum_plus_one.()
7
b(x)
b(x, y)
b(x, y, z)

Specs

b((... -> any), (... -> any), any) :: any
c()

Reverse (first) two arguments (flip). Aliased as flip.

Examples

iex> c(&div/2).(1, 2)
2

iex> reverse_concat = c(&Enum.concat/2)
...> reverse_concat.([1,2,3], [4,5,6])
[4,5,6,1,2,3]

iex> flip(&div/2).(1, 2)
2
c(fun)

Specs

c((... -> any)) :: (... -> any)
flip(fun)

See Quark.BCKW.c/1.

k(a)

See Quark.SKI.k/1.

k(a, b)

See Quark.SKI.k/2.

w()

Apply the same argument to a functon twice

Examples

iex> repeat = w(&Enum.concat/2)
iex> repeat.([1,2])
[1,2,1,2]

iex> w(&Enum.zip/2).([1,2,3])
[{1, 1}, {2, 2}, {3, 3}]
w(fun)

Specs

w((... -> any)) :: any