# View Source Quark.FixedPoint(Quark v2.3.3-doma)

Fixed point combinators generalize the idea of a recursive function. This can be used to great effect, simplifying many definitions.

For example, here is the factorial function written in terms of `y/1`:

``````iex> fac = fn fac ->
...>   fn
...>     0 -> 0
...>     1 -> 1
...>     n -> n * fac.(n - 1)
...>   end
...> end
...> factorial = y(fac)
...> factorial.(9)
362880``````

The resulting function will always be curried

``````iex> import Quark.SKI, only: [s: 3]
...> one_run = y(&s/3)
...> {_, arity} = :erlang.fun_info(one_run, :arity)
...> arity
1``````

# Link to this section Summary

## Functions

Alan Turing's fix-point combinator. This is the call-by-value formulation.

The famous Y-combinator. The resulting function will always be curried.

A normal order fixed point.

View Source

View Source

# turing()

View Source

Alan Turing's fix-point combinator. This is the call-by-value formulation.

## examples Examples

``````iex> fac = fn fac ->
...>   fn
...>     0 -> 0
...>     1 -> 1
...>     n -> n * fac.(n - 1)
...>   end
...> end
...> factorial = turing(fac)
...> factorial.(9)
362880``````

# turing(fun)

View Source
`@spec turing((... -> any())) :: (... -> any())`

# y()

View Source

The famous Y-combinator. The resulting function will always be curried.

## examples Examples

``````iex> fac = fn fac ->
...>   fn
...>     0 -> 0
...>     1 -> 1
...>     n -> n * fac.(n - 1)
...>   end
...> end
...> factorial = y(fac)
...> factorial.(9)
362880``````

# y(fun)

View Source
`@spec y((... -> any())) :: (... -> any())`

# z()

View Source

A normal order fixed point.

## examples Examples

``````iex> fac = fn fac ->
...>   fn
...>     0 -> 0
...>     1 -> 1
...>     n -> n * fac.(n - 1)
...>   end
...> end
...> factorial = z(fac)
...> factorial.(9)
362880``````
`@spec z((... -> any()), any()) :: (... -> any())`