From 930d2b4faf550cb8140084c0df07a9dc9e190c4c Mon Sep 17 00:00:00 2001 From: Brooklyn Zelenka Date: Tue, 30 Aug 2016 05:47:32 +0900 Subject: [PATCH] Version 2.0.0! - Update README with more examples - Improve layout in modules - Move several functions out of top-level into modules - Hence version bump - Update deps --- .gitignore | 1 + README.md | 59 ++- {doc/assets => brand}/logo.png | Bin doc/404.html | 91 ----- doc/Quark.BCKW.html | 390 -------------------- doc/Quark.Compose.html | 460 ----------------------- doc/Quark.Curry.html | 356 ------------------ doc/Quark.FixedPoint.html | 457 ----------------------- doc/Quark.Partial.html | 244 ------------ doc/Quark.SKI.html | 422 --------------------- doc/Quark.Sequence.html | 304 --------------- doc/Quark.html | 656 --------------------------------- doc/api-reference.html | 182 --------- doc/dist/app-6d2e071366.js | 6 - doc/dist/app-ddd9717ad9.css | 1 - doc/dist/sidebar_items.js | 1 - doc/fonts/icomoon.eot | Bin 2472 -> 0 bytes doc/fonts/icomoon.svg | 16 - doc/fonts/icomoon.ttf | Bin 2308 -> 0 bytes doc/fonts/icomoon.woff | Bin 2384 -> 0 bytes doc/index.html | 11 - doc/readme.html | 251 ------------- lib/quark.ex | 74 +--- lib/quark/bckw.ex | 51 ++- lib/quark/compose.ex | 101 +++-- lib/quark/curry.ex | 100 +++-- lib/quark/fixed_point.ex | 125 +++---- lib/quark/m.ex | 26 ++ lib/quark/partial.ex | 81 ++-- lib/quark/sequence.ex | 35 +- lib/quark/ski.ex | 89 +++-- logo.png | Bin 18879 -> 0 bytes mix.exs | 67 ++-- mix.lock | 11 +- test/quark_test.exs | 1 + 35 files changed, 418 insertions(+), 4251 deletions(-) rename {doc/assets => brand}/logo.png (100%) delete mode 100644 doc/404.html delete mode 100644 doc/Quark.BCKW.html delete mode 100644 doc/Quark.Compose.html delete mode 100644 doc/Quark.Curry.html delete mode 100644 doc/Quark.FixedPoint.html delete mode 100644 doc/Quark.Partial.html delete mode 100644 doc/Quark.SKI.html delete mode 100644 doc/Quark.Sequence.html delete mode 100644 doc/Quark.html delete mode 100644 doc/api-reference.html delete mode 100644 doc/dist/app-6d2e071366.js delete mode 100644 doc/dist/app-ddd9717ad9.css delete mode 100644 doc/dist/sidebar_items.js delete mode 100644 doc/fonts/icomoon.eot delete mode 100644 doc/fonts/icomoon.svg delete mode 100644 doc/fonts/icomoon.ttf delete mode 100644 doc/fonts/icomoon.woff delete mode 100644 doc/index.html delete mode 100644 doc/readme.html create mode 100644 lib/quark/m.ex delete mode 100644 logo.png diff --git a/.gitignore b/.gitignore index 6e41e8b..dab1dd8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /_build /cover /deps +/doc erl_crash.dump *.ez *.beam diff --git a/README.md b/README.md index 0aff1b4..1eff5e1 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -![](https://github.com/robot-overlord/quark/blob/master/logo.png?raw=true) +![](https://github.com/expede/quark/blob/master/brand/logo.png?raw=true) ## Common combinators for Elixir | Maintainer Message |Build Status | Doc Coverage | Documentation | Hosted Package | |--------------|--------------------|---------------|---------------|-----------------| -| ![built with humanity](https://cloud.githubusercontent.com/assets/1052016/11023213/66d837a4-8627-11e5-9e3b-b295fafb1450.png) | [![Circle CI](https://circleci.com/gh/robot-overlord/quark/tree/master.svg?style=svg)](https://circleci.com/gh/robot-overlord/quark/tree/master) | [![Inline docs](http://inch-ci.org/github/robot-overlord/quark.svg?branch=master)](http://inch-ci.org/github/robot-overlord/quark) | [hexdocs.pm/quark](https://hexdocs.pm/quark) | [Hex](https://hex.pm/packages/quark) | +| ![built with humanity](https://cloud.githubusercontent.com/assets/1052016/11023213/66d837a4-8627-11e5-9e3b-b295fafb1450.png) | [![Circle CI](https://circleci.com/gh/expede/quark/tree/master.svg?style=svg)](https://circleci.com/gh/expede/quark/tree/master) | [![Inline docs](http://inch-ci.org/github/expede/quark.svg?branch=master)](http://inch-ci.org/github/expede/quark) | [hexdocs.pm/quark](https://hexdocs.pm/quark) | [Hex](https://hex.pm/packages/quark) | # Table of Contents @@ -30,9 +30,14 @@ ```elixir def deps do - [{:quark, "~> 1.0"}] + [{:quark, "~> 2.0"}] end +defmodule MyModule do + use Quark + + # ... +end ``` # Summary @@ -59,7 +64,6 @@ deeper functional composition on functions for reuse. - `fix` - `self_apply` - # Functional Overview ## Curry @@ -155,17 +159,64 @@ algorithm, but not usually with much efficiency. We've aliased the names at the top-level (`Quark`), so you can use `const` rather than having to remember what `k` means. +```elixir + 1 |> i +#=> 1 + +"identity combinator" |> i +#=> "identity combinator" + +Enum.reduce([1,2,3], [42], &k/2) +#=> 3 + +``` + ### BCKW System The classic `b`, `c`, `k`, and `w` combinators. A similar "full system" as SKI, but with some some different functionality out of the box. As usual, we've aliased the names at the top-level (`Quark`). +```elixir +c(&div/2).(1, 2) +#=> 2 + +reverse_concat = c(&Enum.concat/2) +reverse_concat.([1,2,3], [4,5,6]) +#=> [4,5,6,1,2,3] + +repeat = w(&Enum.concat/2) +repeat.([1,2]) +#=> [1,2,1,2] +``` + ### Fixed Point Several fixed point combinators, for helping with recursion. Several formulations are provided, but if in doubt, use `fix`. Fix is going to be kept as an alias to the most efficient formulation at any given time, and thus reasonably future-proof. +```elixir +fac = fn fac -> + fn + 0 -> 0 + 1 -> 1 + n -> n * fac.(n - 1) + end +end + +factorial = y(fac) +factorial.(9) +#=> 362880 +``` + ### Sequence Really here for `pred` and `succ` on integers, by why stop there? This works with any ordered collection via the `Quark.Sequence` protocol. + +```elixir +succ 10 +#=> 11 + +#=> 42 |> origin |> pred |> pred +-2 +``` diff --git a/doc/assets/logo.png b/brand/logo.png similarity index 100% rename from doc/assets/logo.png rename to brand/logo.png diff --git a/doc/404.html b/doc/404.html deleted file mode 100644 index b698dab..0000000 --- a/doc/404.html +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - 404 – Quark v1.0.2 - - - - - -
- - - -
-
- - -

Page not found

- -

Sorry, but the page you were trying to get to, does not exist. You -may want to try searching this site using the sidebar or using our -API Reference page to find what -you were looking for.

- - -
-
-
- - - - diff --git a/doc/Quark.BCKW.html b/doc/Quark.BCKW.html deleted file mode 100644 index 2715f41..0000000 --- a/doc/Quark.BCKW.html +++ /dev/null @@ -1,390 +0,0 @@ - - - - - - - - Quark.BCKW – Quark v1.0.2 - - - - - -
- - - -
-
- - -

- Quark v1.0.2 - Quark.BCKW - - - - - - -

- - -
-

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

- -
- - - -
-

- - - - Summary -

- - - -
-

- Functions -

-
-
- b() -
- -

Normal (binary) function composition

-
- -
-
-
- b(x) -
- -
-
-
- b(x, y) -
- -
-
- - -
-
-
- c() -
- -

Reverse (first) two arguments (flip)

-
- -
-
-
- c(fun) -
- -
-
-
- w() -
- -

Apply the same argument to a functon twice

-
- -
-
-
- w(fun) -
- -
- -
- - - - - - -
- - - - - -
-

- - - - Functions -

-
-
- - - - b() - - - - - -
- -
-

Normal (binary) function composition

-

-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)

-

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

Specs

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

Apply the same argument to a functon twice

-

-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
- -
-
- -
- -
-
- -
- - - - - - -
-
-
- - - - diff --git a/doc/Quark.Compose.html b/doc/Quark.Compose.html deleted file mode 100644 index 4997f2e..0000000 --- a/doc/Quark.Compose.html +++ /dev/null @@ -1,460 +0,0 @@ - - - - - - - - Quark.Compose – Quark v1.0.2 - - - - - -
- - - -
-
- - -

- Quark v1.0.2 - Quark.Compose - - - - - - -

- - -
-

Function composition is taking two functions, and joining them together to create -a new function. For example:

-

-iex> sum_plus_one = compose([&(&1 + 1), &Enum.sum/1])
-iex> sum_plus_one.([1,2,3])
-7
-
-

In this case, we have joined Enum.sum with a function that adds one, to create -a new function that takes a list, sums it, and adds one.

-

Note that composition normally applies from right to left, though Quark -provides the opposite in the form of *_forward functions.

- -
- - - -
-

- - - - Summary -

- - - -
-

- Functions -

-
-
- g <|> f -
- -

Infix compositon operator

-
- -
-
-
- compose() -
- -
-
- - -

Function composition, from the tail of the list to the head

-
- -
-
- - -

Function composition

-
- -
-
- - -

Function composition, from the back of the lift to the front

-
- -
- - -
- - -

Compose functions, from the head of the list of functions. The is the reverse -order versus what one would normally expect (left to right rather than right to left)

-
- -
- - -
- - - - - - -
- - - - - -
-

- - - - Functions -

-
-
- - - - g <|> f - - - - - -
- -
-

Specs

-
- -
(... -> any) <|> (... -> any) :: (... -> any)
- -
-
- -
-

Infix compositon operator

-

-iex> sum_plus_one = fn x -> x + 1 end <|> &Enum.sum/1
-iex> sum_plus_one.([1,2,3])
-7
-
-iex> add_one = &(&1 + 1)
-iex> piped = [1,2,3] |> Enum.sum |> add_one.()
-iex> composed = [1,2,3] |> ((add_one <|> &Enum.sum/1)).()
-iex> piped == composed
-true
-
- -
-
-
-
- - - - compose() - - - - - -
- -
- -
-
-
-
- - - - compose(func_list) - - - - - -
- -
-

Specs

-
- -
compose([(... -> any)]) :: (... -> any)
- -
-
- -
-

Function composition, from the tail of the list to the head

-

-iex> sum_plus_one = compose([&(&1 + 1), &Enum.sum/1])
-iex> [1,2,3] |> sum_plus_one.()
-7
-
- -
-
-
-
- - - - compose(g, f) - - - - - -
- -
-

Specs

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

Function composition

-

-iex> sum_plus_one = compose(&(&1 + 1), &Enum.sum/1)
-iex> [1,2,3] |> sum_plus_one.()
-7
-
- -
-
-
-
- - - - compose_forward() - - - - - -
- -
-

Function composition, from the back of the lift to the front

-

-iex> sum_plus_one = compose_forward(&(Enum.sum(&1)), &(&1 + 1))
-iex> [1,2,3] |> sum_plus_one.()
-7
-
- -
-
-
-
- - - - compose_forward(f) - - - - - -
- -
- -
-
-
-
- - - - compose_forward(f, g) - - - - - -
- -
-

Specs

-
- -
compose_forward((... -> any), (... -> any)) :: (... -> any)
- -
-
- -
- -
-
-
-
- - - - compose_list_forward() - - - - - -
- -
-

Compose functions, from the head of the list of functions. The is the reverse -order versus what one would normally expect (left to right rather than right to left).

-

-iex> sum_plus_one = compose_list_forward([&Enum.sum/1, &(&1 + 1)])
-iex> [1,2,3] |> sum_plus_one.()
-7
-
- -
-
-
-
- - - - compose_list_forward(func_list) - - - - - -
- -
-

Specs

-
- -
compose_list_forward([(... -> any)]) :: (... -> any)
- -
-
- -
- -
-
- -
- - - - - - -
-
-
- - - - diff --git a/doc/Quark.Curry.html b/doc/Quark.Curry.html deleted file mode 100644 index f9b4c54..0000000 --- a/doc/Quark.Curry.html +++ /dev/null @@ -1,356 +0,0 @@ - - - - - - - - Quark.Curry – Quark v1.0.2 - - - - - -
- - - -
-
- - -

- Quark v1.0.2 - Quark.Curry - - - - - - -

- - -
-

Currying breaks up a function into a -series of unary functions that apply their arguments to some inner -n-ary function. This is a convenient way to achieve a general and flexble -partial application on any curried function.

- -
- - - -
-

- - - - Summary -

- - - -
-

- Functions -

-
- - -

This allows you to curry a function at runtime, rather than upon definition

-
- -
-
- - -

Convert a curried function to a function on pairs

-
- -
-
- - -

Apply an argument to a function

-
- -
- -
- - - -
-

- Macros -

-
- - -

Define a curried function

-
- -
-
- - -

Define a curried private function

-
- -
- -
- - - - -
- - - - - -
-

- - - - Functions -

-
-
- - - - curry(fun) - - - - - -
- -
-

Specs

-
- -
curry((... -> any)) :: (any -> any)
- -
-
- -
-

This allows you to curry a function at runtime, rather than upon definition.

-

-iex> curried_reduce_3 = curry &Enum.reduce/3
-iex> {_, arity} = :erlang.fun_info(curried_reduce_3, :arity)
-iex> arity
-1
-
-iex> curried_reduce_3 = curry &Enum.reduce/3
-iex> import Quark.Curry
-iex> curried_reduce_3.([1,2,3]).(42).(&(&1 + &2))
-48
-
- -
-
-
-
- - - - uncurry(fun) - - - - - -
- -
-

Specs

-
- -
uncurry((any -> (any -> any))) :: (any, any -> any)
- -
-
- -
-

Convert a curried function to a function on pairs

-

-iex> curried_add = fn x -> (fn y -> x + y end) end
-iex> add = uncurry curried_add
-iex> add.(1,2)
-3
-
- -
-
-
-
- - - - uncurry(fun, arg) - - - - - -
- -
-

Specs

-
- -
uncurry((... -> any), any) :: any
- -
uncurry((any -> any), [any]) :: any
- -
-
- -
-

Apply an argument to a function

-

-iex> add_one = &(&1 + 1)
-iex> uncurry(add_one, 1)
-2
-
-iex> curried_add = fn x -> (fn y -> x + y end) end
-iex> add_one = uncurry(curried_add, 1)
-iex> add_one.(3)
-4
-
- -
-
- -
- - - -
-

- - - - Macros -

-
-
- - - - defcurry(head, list) - - - - - -
- -
-

Define a curried function

- -
-
-
-
- - - - defcurryp(head, list) - - - - - -
- -
-

Define a curried private function

- -
-
- -
- - - - -
-
-
- - - - diff --git a/doc/Quark.FixedPoint.html b/doc/Quark.FixedPoint.html deleted file mode 100644 index 6ff62ed..0000000 --- a/doc/Quark.FixedPoint.html +++ /dev/null @@ -1,457 +0,0 @@ - - - - - - - - Quark.FixedPoint – Quark v1.0.2 - - - - - -
- - - -
-
- - -

- Quark v1.0.2 - Quark.FixedPoint - - - - - - -

- - -
-

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
-iex> factorial = y fac
-iex> factorial.(9)
-362880
-
-

The resulting functions will always be curried

-

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

- - - - Summary -

- - - -
-

- Functions -

-
-
- fix() -
- - - -
-
-
- fix(a) -
- - - -
-
-
- turing() -
- -

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

-
- -
-
- - -
-
-
- y() -
- -

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

-
- -
-
-
- y(fun) -
- -
-
-
- z() -
- -

A normal order fixed point

-
- -
-
-
- z(g) -
- -
-
-
- z(g, v) -
- -
- -
- - - - - - -
- - - - - -
-

- - - - Functions -

-
-
- - - - fix() - - - - - -
- -
-

See Quark.FixedPoint.y/0.

- -
-
-
-
- - - - fix(a) - - - - - -
- -
-

See Quark.FixedPoint.y/1.

- -
-
-
-
- - - - turing() - - - - - -
- -
-

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

-

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

Specs

-
- -
turing((... -> any)) :: (any -> any)
- -
-
- -
- -
-
-
-
- - - - y() - - - - - -
- -
-

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

-

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

Specs

-
- -
y((... -> any)) :: (any -> any)
- -
-
- -
- -
-
-
-
- - - - z() - - - - - -
- -
-

A normal order fixed point

-

-iex> fac = fn fac ->
-...>   fn
-...>     0 -> 0
-...>     1 -> 1
-...>     n -> n * fac.(n - 1)
-...>   end
-...> end
-iex> factorial = z(fac)
-iex> factorial.(9)
-362880
-
- -
-
-
-
- - - - z(g) - - - - - -
- -
- -
-
-
-
- - - - z(g, v) - - - - - -
- -
-

Specs

-
- -
z((... -> any), any) :: (any -> any)
- -
-
- -
- -
-
- -
- - - - - - -
-
-
- - - - diff --git a/doc/Quark.Partial.html b/doc/Quark.Partial.html deleted file mode 100644 index 948b0c8..0000000 --- a/doc/Quark.Partial.html +++ /dev/null @@ -1,244 +0,0 @@ - - - - - - - - Quark.Partial – Quark v1.0.2 - - - - - -
- - - -
-
- - -

- Quark v1.0.2 - Quark.Partial - - - - - - -

- - -
-

Provide curried functions, that can also be partially bound without dot notation. -Partially applying a function will always return a fully-curried function.

-

Please note that these will use all of the arities up to the defined function. -For example, defpartial foo(a, b, c), do: a + b + c will generate foo/0, foo/1, -foo/2, and foo/3. If you need to use an arity in the range below the original -function, fall back to defcurry and partially apply manually.

- -
- - - -
-

- - - - Summary -

- - - - - -
-

- Macros -

-
- - -

A convenience on defcurry. Generates a series of partially-bound applications -of a fully-curried function, for all arities at and below the user-specified -arity. For instance, defpartial add(a,b), do: a + b will generate add/0, -add/1 and add/2

-
- -
-
- - -

defpartial, but generates private functions

-
- -
- -
- - - - -
- - - - - - - -
-

- - - - Macros -

-
-
- - - - defpartial(arg, list) - - - - - -
- -
-

A convenience on defcurry. Generates a series of partially-bound applications -of a fully-curried function, for all arities at and below the user-specified -arity. For instance, defpartial add(a,b), do: a + b will generate add/0, -add/1 and add/2.

-

-defpartialp minus(a, b, c), do: a - b - c
-
-minus(3, 2, 1)
-# => 0
-
-minus.(3).(2).(1)
-# => 0
-
-below_ten = minus(5)
-below_ten.(2, 1)
-# => 7
-
-below_five = minus(20, 15)
-below_five.(2)
-# => 3
-
- -
-
-
-
- - - - defpartialp(arg, list) - - - - - -
- -
-

defpartial, but generates private functions

-

-defpartialp minus(a, b, c), do: a - b - c
-
-minus(3, 2, 1)
-# => 0
-
-minus.(3).(2).(1)
-# => 0
-
-below10 = minus(5)
-below10.(2, 1)
-# => 7
-
-below5 = minus(10, 5)
-below5.(2)
-# => 3
-
- -
-
- -
- - - - -
-
-
- - - - diff --git a/doc/Quark.SKI.html b/doc/Quark.SKI.html deleted file mode 100644 index 90636e3..0000000 --- a/doc/Quark.SKI.html +++ /dev/null @@ -1,422 +0,0 @@ - - - - - - - - Quark.SKI – Quark v1.0.2 - - - - - -
- - - -
-
- - -

- Quark v1.0.2 - 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

-
- -
-
-
- i(x) -
- -
-
-
- 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

-
- -
-
-
- k(x) -
- -
-
-
- k(x, y) -
- -
-
-
- s() -
- -

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

-
- -
-
-
- s(x) -
- -
-
-
- s(x, y) -
- -
-
- - -
- -
- - - - - - -
- - - - - -
-

- - - - 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
- -
-
- -
- -
-
- -
- - - - - - -
-
-
- - - - diff --git a/doc/Quark.Sequence.html b/doc/Quark.Sequence.html deleted file mode 100644 index d19c115..0000000 --- a/doc/Quark.Sequence.html +++ /dev/null @@ -1,304 +0,0 @@ - - - - - - - - Quark.Sequence – Quark v1.0.2 - - - - - -
- - - -
-
- - -

- Quark v1.0.2 - Quark.Sequence - - protocol - - - - - - -

- - -
- -
- - - -
-

- - - - Summary -

- -
-

- Types -

-
-
- t() -
- -
- -
- - - -
-

- Functions -

-
- - -

The beginning of the sequence

-
- -
-
- - -

The predessor in the sequence

-
- -
-
- - -

The successor in sequence

-
- -
- -
- - - - - - -
- - - -
-

- - - - Types -

-
-
-
t :: term
- -
- -
-
- - - -
-

- - - - Functions -

-
-
- - - - origin(specimen) - - - - - -
- -
-

Specs

-
- -
origin(any) :: any
- -
-
- -
-

The beginning of the sequence.

-

For instance, integers are generally thought of as centering around 0

-

-iex> origin(9)
-0
-
- -
-
-
-
- - - - pred(element) - - - - - -
- -
-

Specs

-
- -
pred(any) :: any
- -
-
- -
-

The predessor in the sequence.

-

For integers, this is the number below.

-

-iex> pred(10)
-9
-
-iex> 42 |> origin |> pred |> pred
--2
-
- -
-
-
-
- - - - succ(element) - - - - - -
- -
-

Specs

-
- -
succ(any) :: any
- -
-
- -
-

The successor in sequence.

-

For integers, this is the number above.

-

-iex> succ(1)
-2
-
-iex> 10 |> origin |> succ |> succ
-2
-
- -
-
- -
- - - - - - -
-
-
- - - - diff --git a/doc/Quark.html b/doc/Quark.html deleted file mode 100644 index c8444c5..0000000 --- a/doc/Quark.html +++ /dev/null @@ -1,656 +0,0 @@ - - - - - - - - Quark – Quark v1.0.2 - - - - - -
- - - -
-
- - -

- Quark v1.0.2 - Quark - - - - - - -

- - -
-

For convenience, many of the most common combinators are available here and given -firendlier names.

-

Due to performance reasons, many of the combinators are given non-combinatory -implementations (ie: not everything is expressed in terms s and k)

- -
- - - -
-

- - - - Summary -

- - - -
-

- Functions -

-
-
- a <|> b -
- - - -
- - -
- - - - -
-
- - - - -
-
-
- fix(f) -
- - - -
-
-
- flip(fun) -
- - - -
-
-
- id(x) -
- - - -
-
-
- m() -
- -

Apply a function to itself

-
- -
-
-
- m(fun) -
- -
-
-
- origin(x) -
- - - -
-
-
- pred(x) -
- - - -
-
-
- second() -
- -

Opposite of first (the k combinator)

-
- -
-
-
- second(a) -
- -
-
- - -
-
- - -

See Quark.m/0

-
- -
-
- - -

See Quark.m/1

-
- -
-
-
- succ(x) -
- - - -
- -
- - - - - - -
- - - - - -
-

- - - - Functions -

-
-
- - - - a <|> b - - - - - -
- -
-

See Quark.Compose.<|>/2.

- -
-
-
-
- - - - compose(list) - - - - - -
- -
-

See Quark.Compose.compose/1.

- -
-
-
-
- - - - compose(a, b) - - - - - -
- -
-

See Quark.Compose.compose/2.

- -
-
-
-
- - - - constant(a, b) - - - - - -
- -
-

See Quark.SKI.k/2.

- -
-
-
-
- - - - first(a, b) - - - - - -
- -
-

See Quark.SKI.k/2.

- -
-
-
-
- - - - fix(f) - - - - - -
- -
-

See Quark.FixedPoint.fix/1.

- -
-
-
-
- - - - flip(fun) - - - - - -
- -
-

See Quark.BCKW.c/1.

- -
-
-
-
- - - - id(x) - - - - - -
- -
-

See Quark.SKI.i/1.

- -
-
-
-
- - - - m() - - - - - -
- -
-

Apply a function to itself

-

-iex> import Quark, only: [m: 1]
-iex> add_one = fn x -> x + 1 end
-iex> add_two = m(add_one)
-iex> add_two.(8)
-10
-
- -
-
-
-
- - - - m(fun) - - - - - -
- -
-

Specs

-
- -
m((... -> any)) :: (... -> any)
- -
-
- -
- -
-
-
-
- - - - origin(x) - - - - - -
- -
-

See Quark.Sequence.origin/1.

- -
-
-
-
- - - - pred(x) - - - - - -
- -
-

See Quark.Sequence.pred/1.

- -
-
-
-
- - - - second() - - - - - -
- -
-

Opposite of first (the k combinator).

-

Returns the second of two arguments. Can be used to repeatedly apply the same value -in functions such as folds.

-

-iex> Quark.second(43, 42)
-42
-
-iex> Enum.reduce([1,2,3], [], &Quark.second/2)
-[]
-
- -
-
-
-
- - - - second(a) - - - - - -
- -
- -
-
-
-
- - - - second(a, b) - - - - - -
- -
-

Specs

-
- -
second(any, any) :: any
- -
-
- -
- -
-
-
-
- - - - self_apply() - - - - - -
- -
-

See Quark.m/0.

- -
-
-
-
- - - - self_apply(fun) - - - - - -
- -
-

See Quark.m/1.

- -
-
-
-
- - - - succ(x) - - - - - -
- -
-

See Quark.Sequence.succ/1.

- -
-
- -
- - - - - - -
-
-
- - - - diff --git a/doc/api-reference.html b/doc/api-reference.html deleted file mode 100644 index 3282d20..0000000 --- a/doc/api-reference.html +++ /dev/null @@ -1,182 +0,0 @@ - - - - - - - - API Reference – Quark v1.0.2 - - - - - -
- - - -
-
- -

- Quark v1.0.2 - API Reference -

- - - - -
-

Modules

-
-
- - -

For convenience, many of the most common combinators are available here and given -firendlier names

-
- -
-
- - -

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

-
- -
-
- - -

Function composition is taking two functions, and joining them together to create -a new function. For example

-
- -
-
- - -

Currying breaks up a function into a -series of unary functions that apply their arguments to some inner -n-ary function. This is a convenient way to achieve a general and flexble -partial application on any curried function

-
- -
-
- - -

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

-
- -
-
- - -

Provide curried functions, that can also be partially bound without dot notation. -Partially applying a function will always return a fully-curried function

-
- -
-
- - -

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

-
- -
- -
-
- - - - - -
-

Protocols

-
-
- - -
- -
- -
-
- - -
-
-
- - - - diff --git a/doc/dist/app-6d2e071366.js b/doc/dist/app-6d2e071366.js deleted file mode 100644 index a5cf0a4..0000000 --- a/doc/dist/app-6d2e071366.js +++ /dev/null @@ -1,6 +0,0 @@ -!function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}(function(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))switch(typeof e[t]){case"function":break;case"object":e[t]=function(t){var n=t.slice(1),r=e[t[0]];return function(e,t,i){r.apply(this,[e,t,i].concat(n))}}(e[t]);break;default:e[t]=e[e[t]]}return e}([function(e,t,n){"use strict";var r=n(1)["default"],i=n(2),a=r(i),o=n(3),s=r(o),l=n(4),c=n(95),u=n(96);window.$=a["default"],a["default"](function(){s["default"].configure({tabReplace:" ",languages:[]}),u.initialize(),c.initialize(),l.initialize(),s["default"].initHighlighting()})},function(e,t){"use strict";t["default"]=function(e){return e&&e.__esModule?e:{"default":e}},t.__esModule=!0},function(e,t,n){var r,i;!function(t,n){"object"==typeof e&&"object"==typeof e.exports?e.exports=t.document?n(t,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return n(e)}:n(t)}("undefined"!=typeof window?window:this,function(n,a){function o(e){var t="length"in e&&e.length,n=re.type(e);return"function"===n||re.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e}function s(e,t,n){if(re.isFunction(t))return re.grep(e,function(e,r){return!!t.call(e,r,e)!==n});if(t.nodeType)return re.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(fe.test(t))return re.filter(t,e,n);t=re.filter(t,e)}return re.grep(e,function(e){return V.call(t,e)>=0!==n})}function l(e,t){for(;(e=e[t])&&1!==e.nodeType;);return e}function c(e){var t=ye[e]={};return re.each(e.match(ve)||[],function(e,n){t[n]=!0}),t}function u(){te.removeEventListener("DOMContentLoaded",u,!1),n.removeEventListener("load",u,!1),re.ready()}function f(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=re.expando+f.uid++}function d(e,t,n){var r;if(void 0===n&&1===e.nodeType)if(r="data-"+t.replace(ke,"-$1").toLowerCase(),n=e.getAttribute(r),"string"==typeof n){try{n="true"===n?!0:"false"===n?!1:"null"===n?null:+n+""===n?+n:Ee.test(n)?re.parseJSON(n):n}catch(i){}we.set(e,t,n)}else n=void 0;return n}function p(){return!0}function h(){return!1}function g(){try{return te.activeElement}catch(e){}}function m(e,t){return re.nodeName(e,"table")&&re.nodeName(11!==t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function v(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function y(e){var t=Be.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function b(e,t){for(var n=0,r=e.length;r>n;n++)_e.set(e[n],"globalEval",!t||_e.get(t[n],"globalEval"))}function x(e,t){var n,r,i,a,o,s,l,c;if(1===t.nodeType){if(_e.hasData(e)&&(a=_e.access(e),o=_e.set(t,a),c=a.events)){delete o.handle,o.events={};for(i in c)for(n=0,r=c[i].length;r>n;n++)re.event.add(t,i,c[i][n])}we.hasData(e)&&(s=we.access(e),l=re.extend({},s),we.set(t,l))}}function _(e,t){var n=e.getElementsByTagName?e.getElementsByTagName(t||"*"):e.querySelectorAll?e.querySelectorAll(t||"*"):[];return void 0===t||t&&re.nodeName(e,t)?re.merge([e],n):n}function w(e,t){var n=t.nodeName.toLowerCase();"input"===n&&Se.test(e.type)?t.checked=e.checked:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}function E(e,t){var r,i=re(t.createElement(e)).appendTo(t.body),a=n.getDefaultComputedStyle&&(r=n.getDefaultComputedStyle(i[0]))?r.display:re.css(i[0],"display");return i.detach(),a}function k(e){var t=te,n=We[e];return n||(n=E(e,t),"none"!==n&&n||(ze=(ze||re("