Skip to content

Instantly share code, notes, and snippets.

@dwickstrom
Forked from Avaq/combinators.js
Last active June 13, 2018 12:13
Show Gist options
  • Select an option

  • Save dwickstrom/b8b6e46bff1111097945a68de4b9762f to your computer and use it in GitHub Desktop.

Select an option

Save dwickstrom/b8b6e46bff1111097945a68de4b9762f to your computer and use it in GitHub Desktop.

Revisions

  1. dwickstrom revised this gist Jun 13, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion combinators.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ identity | **I** | Idiot | `id` | `identity` | `I`
    constant | **K** | Kestrel | `const` | `always` | `K` | `a → b → a`
    apply | **A** | | `($)` | `call` | `A` | `(a → b) → a → b`
    thrush | **T** | Thrush | `(&)` | `applyTo` | `T` | `a → (a → b) → b`
    duplication | **W** | | `join`² | `unnest`² | `join`² | `(a → a → b) → a → b`
    duplication | **W** | Warble | `join`² | `unnest`² | `join`² | `(a → a → b) → a → b`
    flip | **C** | Cardinal | `flip` | `flip` | `flip` | `(a → b → c) → b → a → c`
    compose | **B** | Bluebird | `(.)`, `fmap`² | `map`² | `compose`, `map`² | `(b → c) → (a → b) → a → c`
    substitution | **S** | Starling | `ap`² | `ap`² | `ap`² | `(a → b → c) → (a → b) → a → c`
  2. dwickstrom revised this gist Jun 13, 2018. 1 changed file with 12 additions and 12 deletions.
    24 changes: 12 additions & 12 deletions combinators.md
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,15 @@
    Name | # | [Haskell][] | [Ramda][] | [Sanctuary][] | Signature
    ------------:|-------|----------------|------------|-------------------|----------
    identity | **I** | `id` | `identity` | `I` | `a → a`
    constant | **K** | `const` | `always` | `K` | `a → b → a`
    apply | **A** | `($)` | `call` | `A` | `(a → b) → a → b`
    thrush | **T** | `(&)` | `applyTo` | `T` | `a → (a → b) → b`
    duplication | **W** | `join`² | `unnest`² | `join`² | `(a → a → b) → a → b`
    flip | **C** | `flip` | `flip` | `flip` | `(a → b → c) → b → a → c`
    compose | **B** | `(.)`, `fmap`² | `map`² | `compose`, `map`² | `(b → c) → (a → b) → a → c`
    substitution | **S** | `ap`² | `ap`² | `ap`² | `(a → b → c) → (a → b) → a → c`
    psi | **P** | `on` | | `on` | `(b → b → c) → (a → b) → a → a → c`
    fix-point¹ | **Y** | `fix` | | | `(a → a) → a`
    Name | # |Birds | [Haskell][] | [Ramda][] | [Sanctuary][] | Signature
    ------------:|-------|--------------|----------------|------------|-------------------|----------
    identity | **I** | Idiot | `id` | `identity` | `I` | `a → a`
    constant | **K** | Kestrel | `const` | `always` | `K` | `a → b → a`
    apply | **A** | | `($)` | `call` | `A` | `(a → b) → a → b`
    thrush | **T** | Thrush | `(&)` | `applyTo` | `T` | `a → (a → b) → b`
    duplication | **W** | | `join`² | `unnest`² | `join`² | `(a → a → b) → a → b`
    flip | **C** | Cardinal | `flip` | `flip` | `flip` | `(a → b → c) → b → a → c`
    compose | **B** | Bluebird | `(.)`, `fmap`² | `map`² | `compose`, `map`² | `(b → c) → (a → b) → a → c`
    substitution | **S** | Starling | `ap`² | `ap`² | `ap`² | `(a → b → c) → (a → b) → a → c`
    psi | **P** | | `on` | | `on` | `(b → b → c) → (a → b) → a → a → c`
    fix-point¹ | **Y** | | `fix` | | | `(a → a) → a`

    -----

  3. @Avaq Avaq revised this gist Jan 4, 2018. 1 changed file with 13 additions and 10 deletions.
    23 changes: 13 additions & 10 deletions references.md
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,13 @@
    * [Combinator Birds](http://www.angelfire.com/tx4/cus/combinator/birds.html)
    * [CombinatorsJS](https://github.com/benji6/combinators-js)
    * [Collected Lambdas](http://jwodder.freeshell.org/lambda.html)
    * [To Mock a Mocking Bird](https://www.amazon.com/Mock-Mockingbird-Other-Logic-Puzzles/dp/0192801422)
    * [Fantasy Combinators](https://github.com/fantasyland/fantasy-combinators)
    * [Fixed-point combinator](https://en.wikipedia.org/wiki/Fixed-point_combinator)
    * [Lambda calculus](https://en.wikipedia.org/wiki/Lambda_calculus)
    * [SKI combinator calculus](https://en.wikipedia.org/wiki/SKI_combinator_calculus)
    * [BCKW combinator calculus](https://en.wikipedia.org/wiki/B,_C,_K,_W_system)
    * [Programming With Nothing](http://rubymanor.org/3/videos/programming_with_nothing)
    Note that when I use the word "combinator" in this context, it implies "function combinator in the untyped lambda calculus".

    * [To Mock a Mocking Bird](https://www.amazon.com/Mock-Mockingbird-Other-Logic-Puzzles/dp/0192801422) (book of combinatory puzzles and examples)
    * [Combinator Birds](http://www.angelfire.com/tx4/cus/combinator/birds.html) (summary of all combinators named by the book)
    * [CombinatorsJS](https://github.com/benji6/combinators-js) (implementation of all the same combinators in JavaScripts)
    * [Fantasy Combinators](https://github.com/fantasyland/fantasy-combinators) (implementation of common combinators in JavaScript)
    * [Collected Lambdas](http://jwodder.freeshell.org/lambda.html) (collection of noteworthy combinators)
    * [Programming With Nothing](http://rubymanor.org/3/videos/programming_with_nothing) (talk)
    * [Church Encoding](https://en.wikipedia.org/wiki/Church_encoding) (wikipedia)
    * [Fixed-point combinator](https://en.wikipedia.org/wiki/Fixed-point_combinator) (wikipedia)
    * [Lambda calculus](https://en.wikipedia.org/wiki/Lambda_calculus) (wikipedia)
    * [SKI combinator calculus](https://en.wikipedia.org/wiki/SKI_combinator_calculus) (wikipedia)
    * [BCKW combinator calculus](https://en.wikipedia.org/wiki/B,_C,_K,_W_system) (wikipedia)
  4. @Avaq Avaq revised this gist Dec 22, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion combinators.md
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@ Name | # | [Haskell][] | [Ramda][] | [Sanctuary][] | Signatu
    identity | **I** | `id` | `identity` | `I` | `a → a`
    constant | **K** | `const` | `always` | `K` | `a → b → a`
    apply | **A** | `($)` | `call` | `A` | `(a → b) → a → b`
    thrush | **T** | `(&)` | | `T` | `a → (a → b) → b`
    thrush | **T** | `(&)` | `applyTo` | `T` | `a → (a → b) → b`
    duplication | **W** | `join`² | `unnest`² | `join`² | `(a → a → b) → a → b`
    flip | **C** | `flip` | `flip` | `flip` | `(a → b → c) → b → a → c`
    compose | **B** | `(.)`, `fmap`² | `map`² | `compose`, `map`² | `(b → c) → (a → b) → a → c`
  5. @Avaq Avaq revised this gist Aug 28, 2017. 1 changed file with 12 additions and 12 deletions.
    24 changes: 12 additions & 12 deletions combinators.md
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,15 @@
    Name | # | [Haskell][] | [Ramda][] | [Sanctuary][] | Signature
    ------------:|-------|-------------|--------------------|------------------------|----------
    identity | **I** | `id` | `identity` | `I` | `a → a`
    constant | **K** | `const` | `always` | `K` | `a → b → a`
    apply | **A** | `($)` | `call` | `A` | `(a → b) → a → b`
    thrush | **T** | `(&)` | | `T` | `a → (a → b) → b`
    duplication | **W** | `join`² | `unnest`² | `join`² | `(a → a → b) → a → b`
    flip | **C** | `flip` | `flip` | `flip` | `(a → b → c) → b → a → c`
    compose | **B** | `(.)` | `map`² | `compose`, `map`² | `(b → c) → (a → b) → a → c`
    substitution | **S** | `ap`² | `ap`² | `ap`² | `(a → b → c) → (a → b) → a → c`
    psi | **P** | `on` | | `on` | `(b → b → c) → (a → b) → a → a → c`
    fix-point¹ | **Y** | `fix` | | | `(a → a) → a`
    Name | # | [Haskell][] | [Ramda][] | [Sanctuary][] | Signature
    ------------:|-------|----------------|------------|-------------------|----------
    identity | **I** | `id` | `identity` | `I` | `a → a`
    constant | **K** | `const` | `always` | `K` | `a → b → a`
    apply | **A** | `($)` | `call` | `A` | `(a → b) → a → b`
    thrush | **T** | `(&)` | | `T` | `a → (a → b) → b`
    duplication | **W** | `join`² | `unnest`² | `join`² | `(a → a → b) → a → b`
    flip | **C** | `flip` | `flip` | `flip` | `(a → b → c) → b → a → c`
    compose | **B** | `(.)`, `fmap`² | `map`² | `compose`, `map`² | `(b → c) → (a → b) → a → c`
    substitution | **S** | `ap`² | `ap`² | `ap`² | `(a → b → c) → (a → b) → a → c`
    psi | **P** | `on` | | `on` | `(b → b → c) → (a → b) → a → a → c`
    fix-point¹ | **Y** | `fix` | | | `(a → a) → a`

    -----

  6. @Avaq Avaq revised this gist Jun 9, 2017. No changes.
  7. @Avaq Avaq revised this gist Feb 13, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion combinators.md
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ substitution | **S** | `ap`² | `ap`² | `ap`²
    psi | **P** | `on` | | `on` | `(b → b → c) → (a → b) → a → a → c`
    fix-point¹ | **Y** | `fix` | | | `(a → a) → a`

    **Notes**
    -----

    ¹) In JavaScript and other non-lazy languages, it is impossible to implement the
    Y-combinator. Instead a variant known as the *applicative* or *strict*
  8. @Avaq Avaq revised this gist Feb 13, 2017. 1 changed file with 4 additions and 12 deletions.
    16 changes: 4 additions & 12 deletions combinators.md
    Original file line number Diff line number Diff line change
    @@ -4,10 +4,10 @@ identity | **I** | `id` | `identity` | `I`
    constant | **K** | `const` | `always` | `K` | `a → b → a`
    apply | **A** | `($)` | `call` | `A` | `(a → b) → a → b`
    thrush | **T** | `(&)` | | `T` | `a → (a → b) → b`
    duplication | **W** | `join`³ | `unnest`³ | `join`³ | `(a → a → b) → a → b`
    duplication | **W** | `join`² | `unnest`² | `join`² | `(a → a → b) → a → b`
    flip | **C** | `flip` | `flip` | `flip` | `(a → b → c) → b → a → c`
    compose | **B** | `(.)` | `compose`², `map`³ | `compose`, `map`³ | `(b → c) → (a → b) → a → c`
    substitution | **S** | `ap`³ | `ap`³ | `ap`³ | `(a → b → c) → (a → b) → a → c`
    compose | **B** | `(.)` | `map`² | `compose`, `map`² | `(b → c) → (a → b) → a → c`
    substitution | **S** | `ap`² | `ap`² | `ap`² | `(a → b → c) → (a → b) → a → c`
    psi | **P** | `on` | | `on` | `(b → b → c) → (a → b) → a → a → c`
    fix-point¹ | **Y** | `fix` | | | `(a → a) → a`

    @@ -18,15 +18,7 @@ fix-point¹ | **Y** | `fix` | |
    fix-point combinator is implemented. This variant is sometimes rererred to as
    the Z-combinator.

    ²) Ramda's `compose` behaves like the composition combinator only when:
    * Both arguments are passed at the same time. Partial application does
    not work.
    * The number of functions given is exactly 2. All input functions are
    composed together in a fashion similar to `pipe`.
    * The second input function is unary. The output function shares arity
    with the last input function provided.

    ³) Algebras like `ap` have different implementations for different types.
    ²) Algebras like `ap` have different implementations for different types.
    They work like Function combinators only for Function inputs.

    [Haskell]: https://www.haskell.org/
  9. @Avaq Avaq revised this gist Feb 13, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion combinators.md
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ duplication | **W** | `join`³ | `unnest`³ | `join`³
    flip | **C** | `flip` | `flip` | `flip` | `(a → b → c) → b → a → c`
    compose | **B** | `(.)` | `compose`², `map`³ | `compose`, `map`³ | `(b → c) → (a → b) → a → c`
    substitution | **S** | `ap`³ | `ap`³ | `ap`³ | `(a → b → c) → (a → b) → a → c`
    psi | **P** | `on` | | | `(b → b → c) → (a → b) → a → a → c`
    psi | **P** | `on` | | `on` | `(b → b → c) → (a → b) → a → a → c`
    fix-point¹ | **Y** | `fix` | | | `(a → a) → a`

    **Notes**
  10. @Avaq Avaq revised this gist Feb 8, 2017. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion references.md
    Original file line number Diff line number Diff line change
    @@ -6,4 +6,5 @@
    * [Fixed-point combinator](https://en.wikipedia.org/wiki/Fixed-point_combinator)
    * [Lambda calculus](https://en.wikipedia.org/wiki/Lambda_calculus)
    * [SKI combinator calculus](https://en.wikipedia.org/wiki/SKI_combinator_calculus)
    * [BCKW combinator calculus](https://en.wikipedia.org/wiki/B,_C,_K,_W_system)
    * [BCKW combinator calculus](https://en.wikipedia.org/wiki/B,_C,_K,_W_system)
    * [Programming With Nothing](http://rubymanor.org/3/videos/programming_with_nothing)
  11. @Avaq Avaq revised this gist Feb 4, 2017. 1 changed file with 12 additions and 12 deletions.
    24 changes: 12 additions & 12 deletions combinators.md
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,15 @@
    Name | # | [Haskell][] | [Ramda][] | [Sanctuary][] | Signature
    ------------:|-------|-------------|------------|------------------------|----------
    identity | **I** | `id` | `identity` | `I` | `a → a`
    constant | **K** | `const` | `always` | `K` | `a → b → a`
    apply | **A** | `($)` | `call` | `A` | `(a → b) → a → b`
    thrush | **T** | `(&)` | | `T` | `a → (a → b) → b`
    duplication | **W** | `join`³ | | `join`³ | `(a → a → b) → a → b`
    flip | **C** | `flip` | `flip` | `flip` | `(a → b → c) → b → a → c`
    compose | **B** | `(.)` | `compose`² | `compose`, `map`³ | `(b → c) → (a → b) → a → c`
    substitution | **S** | `ap`³ | `ap`³ | `ap`³ | `(a → b → c) → (a → b) → a → c`
    psi | **P** | `on` | | | `(b → b → c) → (a → b) → a → a → c`
    fix-point¹ | **Y** | `fix` | | | `(a → a) → a`
    Name | # | [Haskell][] | [Ramda][] | [Sanctuary][] | Signature
    ------------:|-------|-------------|--------------------|------------------------|----------
    identity | **I** | `id` | `identity` | `I` | `a → a`
    constant | **K** | `const` | `always` | `K` | `a → b → a`
    apply | **A** | `($)` | `call` | `A` | `(a → b) → a → b`
    thrush | **T** | `(&)` | | `T` | `a → (a → b) → b`
    duplication | **W** | `join`³ | `unnest`³ | `join`³ | `(a → a → b) → a → b`
    flip | **C** | `flip` | `flip` | `flip` | `(a → b → c) → b → a → c`
    compose | **B** | `(.)` | `compose`², `map`³ | `compose`, `map`³ | `(b → c) → (a → b) → a → c`
    substitution | **S** | `ap`³ | `ap`³ | `ap`³ | `(a → b → c) → (a → b) → a → c`
    psi | **P** | `on` | | | `(b → b → c) → (a → b) → a → a → c`
    fix-point¹ | **Y** | `fix` | | | `(a → a) → a`

    **Notes**

  12. @Avaq Avaq revised this gist Feb 4, 2017. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions combinators.md
    Original file line number Diff line number Diff line change
    @@ -5,9 +5,9 @@ constant | **K** | `const` | `always` | `K` | `a
    apply | **A** | `($)` | `call` | `A` | `(a → b) → a → b`
    thrush | **T** | `(&)` | | `T` | `a → (a → b) → b`
    duplication | **W** | `join`³ | | `join`³ | `(a → a → b) → a → b`
    flip | **C** | `flip` | `flip` | `C` | `(a → b → c) → b → a → c`
    compose | **B** | `(.)` | `compose`² | `B`, `compose`, `map`³ | `(b → c) → (a → b) → a → c`
    substitution | **S** | `ap`³ | `ap`³ | `S`, `ap`³ | `(a → b → c) → (a → b) → a → c`
    flip | **C** | `flip` | `flip` | `flip` | `(a → b → c) → b → a → c`
    compose | **B** | `(.)` | `compose`² | `compose`, `map`³ | `(b → c) → (a → b) → a → c`
    substitution | **S** | `ap`³ | `ap`³ | `ap`³ | `(a → b → c) → (a → b) → a → c`
    psi | **P** | `on` | | | `(b → b → c) → (a → b) → a → a → c`
    fix-point¹ | **Y** | `fix` | | | `(a → a) → a`

    @@ -27,7 +27,7 @@ fix-point¹ | **Y** | `fix` | | | `(a
    with the last input function provided.

    ³) Algebras like `ap` have different implementations for different types.
    They work like combinators only for Function inputs.
    They work like Function combinators only for Function inputs.

    [Haskell]: https://www.haskell.org/
    [Ramda]: http://ramdajs.com/
  13. @Avaq Avaq revised this gist Feb 4, 2017. 1 changed file with 14 additions and 15 deletions.
    29 changes: 14 additions & 15 deletions combinators.md
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,15 @@
    Name | # | [Haskell][] | [Ramda][] | [Sanctuary][] | Signature
    ------------:|-------|-------------|------------|---------------|----------
    identity | **I** | `id` | `identity` | `I` | `a → a`
    constant | **K** | `const` | `always` | `K` | `a → b → a`
    apply | **A** | `($)` | `call` | `A` | `(a → b) → a → b`
    thrush | **T** | `(&)` | | `T` | `a → (a → b) → b`
    duplication | **W** | | | | `(a → a → b) → a → b`
    flip | **C** | `flip` | `flip` | `C` | `(a → b → c) → b → a → c`
    compose | **B** | `(.)` | `compose`² | `B` | `(b → c) → (a → b) → a → c`
    substitution | **S** | | `ap`³ | `S` | `(a → b → c) → (a → b) → a → c`
    psi | **P** | `on` | | | `(b → b → c) → (a → b) → a → a → c`
    fix-point¹ | **Y** | `fix` | | | `(a → a) → a`
    Name | # | [Haskell][] | [Ramda][] | [Sanctuary][] | Signature
    ------------:|-------|-------------|------------|------------------------|----------
    identity | **I** | `id` | `identity` | `I` | `a → a`
    constant | **K** | `const` | `always` | `K` | `a → b → a`
    apply | **A** | `($)` | `call` | `A` | `(a → b) → a → b`
    thrush | **T** | `(&)` | | `T` | `a → (a → b) → b`
    duplication | **W** | `join`³ | | `join`³ | `(a → a → b) → a → b`
    flip | **C** | `flip` | `flip` | `C` | `(a → b → c) → b → a → c`
    compose | **B** | `(.)` | `compose`² | `B`, `compose`, `map`³ | `(b → c) → (a → b) → a → c`
    substitution | **S** | `ap`³ | `ap`³ | `S`, `ap`³ | `(a → b → c) → (a → b) → a → c`
    psi | **P** | `on` | | | `(b → b → c) → (a → b) → a → a → c`
    fix-point¹ | **Y** | `fix` | | | `(a → a) → a`

    **Notes**

    @@ -26,9 +26,8 @@ fix-point¹ | **Y** | `fix` | | | `(a → a)
    * The second input function is unary. The output function shares arity
    with the last input function provided.

    ³) Ramda's `ap` behaves like the substitution combinator only when given the
    the input that `S` would take. For any other applicatives `ap` will run
    different logic.
    ³) Algebras like `ap` have different implementations for different types.
    They work like combinators only for Function inputs.

    [Haskell]: https://www.haskell.org/
    [Ramda]: http://ramdajs.com/
  14. @Avaq Avaq revised this gist Nov 21, 2016. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions references.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    * [Combinator Birds](http://www.angelfire.com/tx4/cus/combinator/birds.html)
    * [CombinatorsJS](https://github.com/benji6/combinators-js)
    * [Collected Lambdas](http://jwodder.freeshell.org/lambda.html)
    * [To Mock a Mocking Bird](https://www.amazon.com/Mock-Mockingbird-Other-Logic-Puzzles/dp/0192801422)
    * [Fantasy Combinators](https://github.com/fantasyland/fantasy-combinators)
  15. @Avaq Avaq revised this gist Nov 11, 2016. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions references.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    * [Collected Lambdas](http://jwodder.freeshell.org/lambda.html)
    * [To Mock a Mocking Bird](https://www.amazon.com/Mock-Mockingbird-Other-Logic-Puzzles/dp/0192801422)
    * [Fantasy Combinators](https://github.com/fantasyland/fantasy-combinators)
    * [Fixed-point combinator](https://en.wikipedia.org/wiki/Fixed-point_combinator)
    * [Lambda calculus](https://en.wikipedia.org/wiki/Lambda_calculus)
    * [SKI combinator calculus](https://en.wikipedia.org/wiki/SKI_combinator_calculus)
  16. @Avaq Avaq revised this gist Nov 11, 2016. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion references.md
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,6 @@
    * [Collected Lambdas](http://jwodder.freeshell.org/lambda.html)
    * [SKI combinator calculus](https://en.wikipedia.org/wiki/SKI_combinator_calculus)
    * [To Mock a Mocking Bird](https://www.amazon.com/Mock-Mockingbird-Other-Logic-Puzzles/dp/0192801422)
    * [Fixed-point combinator](https://en.wikipedia.org/wiki/Fixed-point_combinator)
    * [Lambda calculus](https://en.wikipedia.org/wiki/Lambda_calculus)
    * [SKI combinator calculus](https://en.wikipedia.org/wiki/SKI_combinator_calculus)
    * [BCKW combinator calculus](https://en.wikipedia.org/wiki/B,_C,_K,_W_system)
  17. @Avaq Avaq revised this gist Nov 11, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions references.md
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,2 @@
    [Collected Lambdas](http://jwodder.freeshell.org/lambda.html)
    [SKI combinator calculus](https://en.wikipedia.org/wiki/SKI_combinator_calculus)
    * [Collected Lambdas](http://jwodder.freeshell.org/lambda.html)
    * [SKI combinator calculus](https://en.wikipedia.org/wiki/SKI_combinator_calculus)
  18. @Avaq Avaq revised this gist Nov 11, 2016. 2 changed files with 2 additions and 1 deletion.
    2 changes: 1 addition & 1 deletion combinators.md
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@ fix-point¹ | **Y** | `fix` | | | `(a → a)

    ¹) In JavaScript and other non-lazy languages, it is impossible to implement the
    Y-combinator. Instead a variant known as the *applicative* or *strict*
    fix-point combinator is implemented. This variant is commonly rererred to as
    fix-point combinator is implemented. This variant is sometimes rererred to as
    the Z-combinator.

    ²) Ramda's `compose` behaves like the composition combinator only when:
    1 change: 1 addition & 0 deletions references.md
    Original file line number Diff line number Diff line change
    @@ -1 +1,2 @@
    [Collected Lambdas](http://jwodder.freeshell.org/lambda.html)
    [SKI combinator calculus](https://en.wikipedia.org/wiki/SKI_combinator_calculus)
  19. @Avaq Avaq revised this gist Jun 28, 2016. 4 changed files with 0 additions and 26 deletions.
    7 changes: 0 additions & 7 deletions SKI.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +0,0 @@
    const S = f => g => x => f(x)(g(x))
    const K = x => y => x

    const I = S(K)(K)
    const B = S(K(S))(K)
    const C = S(S(K(S(K(S))(K)))(S))(K(K))
    const W = S(S)(K(S(K)(K)))
    File renamed without changes.
    8 changes: 0 additions & 8 deletions pointfree-factorial.js
    Original file line number Diff line number Diff line change
    @@ -1,8 +0,0 @@
    const ifElse = f => g => h => x => f(x) ? g(x) : h(x);
    const isZero = a => a < 1;
    const mult = a => b => a * b;
    const dec = a => a - 1;

    const factorial = Y(B(ifElse(isZero)(K(1)))(B(S(mult))(C(B)(dec))));

    factorial(4);
    11 changes: 0 additions & 11 deletions y.js
    Original file line number Diff line number Diff line change
    @@ -1,11 +0,0 @@
    const head = xs => xs[0];
    const tail = xs => xs.slice(1);
    const add = a => b => a + b;

    const dot = Y(f => n => n < 1 ? '' : '.' + f(n - 1));
    const factorial = Y(f => n => n < 1 ? 1 : n * f(n - 1));
    const reduce = f => Y(g => y => xs => xs.length < 1 ? y : g(f(y)(head(xs)))(tail(xs)));

    dot(3) //> "..."
    factorial(4) //> 24
    reduce(add)(0)([1, 2, 3]) //> 6
  20. @Avaq Avaq revised this gist Jun 20, 2016. 1 changed file with 7 additions and 4 deletions.
    11 changes: 7 additions & 4 deletions combinators.md
    Original file line number Diff line number Diff line change
    @@ -18,10 +18,13 @@ fix-point¹ | **Y** | `fix` | | | `(a → a)
    fix-point combinator is implemented. This variant is commonly rererred to as
    the Z-combinator.

    ²) Ramda's `compose` behaves like the composition combinator only when given a
    unary function as input. For any other arity it's going to return a function
    which shares that arity. Ramda's `compose` is incapable of being partially
    applied with its first argument. The first two *must* be given at once.
    ²) Ramda's `compose` behaves like the composition combinator only when:
    * Both arguments are passed at the same time. Partial application does
    not work.
    * The number of functions given is exactly 2. All input functions are
    composed together in a fashion similar to `pipe`.
    * The second input function is unary. The output function shares arity
    with the last input function provided.

    ³) Ramda's `ap` behaves like the substitution combinator only when given the
    the input that `S` would take. For any other applicatives `ap` will run
  21. @Avaq Avaq revised this gist Jun 20, 2016. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion combinators.md
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,8 @@ fix-point¹ | **Y** | `fix` | | | `(a → a)

    ²) Ramda's `compose` behaves like the composition combinator only when given a
    unary function as input. For any other arity it's going to return a function
    which shares that arity.
    which shares that arity. Ramda's `compose` is incapable of being partially
    applied with its first argument. The first two *must* be given at once.

    ³) Ramda's `ap` behaves like the substitution combinator only when given the
    the input that `S` would take. For any other applicatives `ap` will run
  22. @Avaq Avaq revised this gist Jun 17, 2016. 1 changed file with 26 additions and 14 deletions.
    40 changes: 26 additions & 14 deletions combinators.md
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,31 @@
    Name | # | Haskell | Ramda | S | Signature
    ------------:|-------|---------|----------|---|----------
    identity | **I** | id | identity | | `a → a`
    constant | **K** | const | always | | `a → b → a`
    apply | **A** | ($) | call | | `(a → b) → a → b`
    thrush | **T** | (&) | | ✓ | `a → (a → b) → b`
    duplication | **W** | | | | `(a → a → b) → a → b`
    flip | **C** | flip | flip | | `(a → b → c) → b → a → c`
    compose | **B** | (.) | compose | ✓ | `(b → c) → (a → b) → a → c`
    substitution | **S** | | ap | ✓ | `(a → b → c) → (a → b) → a → c`
    psi | **P** | on | | | `(b → b → c) → (a → b) → a → a → c`
    fix-point\* | **Y** | fix | | | `(a → a) → a`
    Name | # | [Haskell][] | [Ramda][] | [Sanctuary][] | Signature
    ------------:|-------|-------------|------------|---------------|----------
    identity | **I** | `id` | `identity` | `I` | `a → a`
    constant | **K** | `const` | `always` | `K` | `a → b → a`
    apply | **A** | `($)` | `call` | `A` | `(a → b) → a → b`
    thrush | **T** | `(&)` | | `T` | `a → (a → b) → b`
    duplication | **W** | | | | `(a → a → b) → a → b`
    flip | **C** | `flip` | `flip` | `C` | `(a → b → c) → b → a → c`
    compose | **B** | `(.)` | `compose`² | `B` | `(b → c) → (a → b) → a → c`
    substitution | **S** | | `ap`³ | `S` | `(a → b → c) → (a → b) → a → c`
    psi | **P** | `on` | | | `(b → b → c) → (a → b) → a → a → c`
    fix-point¹ | **Y** | `fix` | | | `(a → a) → a`

    \* In JavaScript and other non-lazy languages, it is impossible to implement the
    **Notes**

    ¹) In JavaScript and other non-lazy languages, it is impossible to implement the
    Y-combinator. Instead a variant known as the *applicative* or *strict*
    fix-point combinator is implemented. This variant is commonly rererred to as
    the Z-combinator.

    S: Whether the combinator was added to [Sanctuary](http://sanctuary.js.org/#combinator).
    ²) Ramda's `compose` behaves like the composition combinator only when given a
    unary function as input. For any other arity it's going to return a function
    which shares that arity.

    ³) Ramda's `ap` behaves like the substitution combinator only when given the
    the input that `S` would take. For any other applicatives `ap` will run
    different logic.

    [Haskell]: https://www.haskell.org/
    [Ramda]: http://ramdajs.com/
    [Sanctuary]: http://sanctuary.js.org/#combinator
  23. @Avaq Avaq revised this gist Jun 14, 2016. 1 changed file with 15 additions and 13 deletions.
    28 changes: 15 additions & 13 deletions combinators.md
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,19 @@
    Name | # | Haskell | Ramda | Signature
    ------------:|-------|---------|----------|----------
    identity | **I** | id | identity | `a → a`
    constant | **K** | const | always | `a → b → a`
    apply | **A** | ($) | call | `(a → b) → a → b`
    thrush | **T** | (&) | | `a → (a → b) → b`
    duplication | **W** | | | `(a → a → b) → a → b`
    flip | **C** | flip | flip | `(a → b → c) → b → a → c`
    compose | **B** | (.) | compose | `(b → c) → (a → b) → a → c`
    substitution | **S** | | ap | `(a → b → c) → (a → b) → a → c`
    psi | **P** | on | | `(b → b → c) → (a → b) → a → a → c`
    fix-point\* | **Y** | fix | | `(a → a) → a`
    Name | # | Haskell | Ramda | S | Signature
    ------------:|-------|---------|----------|---|----------
    identity | **I** | id | identity | ✓ | `a → a`
    constant | **K** | const | always | ✓ | `a → b → a`
    apply | **A** | ($) | call | ✓ | `(a → b) → a → b`
    thrush | **T** | (&) | | ✓ | `a → (a → b) → b`
    duplication | **W** | | | | `(a → a → b) → a → b`
    flip | **C** | flip | flip | ✓ | `(a → b → c) → b → a → c`
    compose | **B** | (.) | compose | ✓ | `(b → c) → (a → b) → a → c`
    substitution | **S** | | ap | ✓ | `(a → b → c) → (a → b) → a → c`
    psi | **P** | on | | | `(b → b → c) → (a → b) → a → a → c`
    fix-point\* | **Y** | fix | | | `(a → a) → a`

    \* In JavaScript and other non-lazy languages, it is impossible to implement the
    Y-combinator. Instead a variant known as the *applicative* or *strict*
    fix-point combinator is implemented. This variant is commonly rererred to as
    the Z-combinator.
    the Z-combinator.

    S: Whether the combinator was added to [Sanctuary](http://sanctuary.js.org/#combinator).
  24. @Avaq Avaq revised this gist Jun 14, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion combinators.md
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ thrush | **T** | (&) | | `a → (a → b) → b`
    duplication | **W** | | | `(a → a → b) → a → b`
    flip | **C** | flip | flip | `(a → b → c) → b → a → c`
    compose | **B** | (.) | compose | `(b → c) → (a → b) → a → c`
    substitution | **S** | | | `(a → b → c) → (a → b) → a → c`
    substitution | **S** | | ap | `(a → b → c) → (a → b) → a → c`
    psi | **P** | on | | `(b → b → c) → (a → b) → a → a → c`
    fix-point\* | **Y** | fix | | `(a → a) → a`

  25. @Avaq Avaq renamed this gist Apr 21, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  26. @Avaq Avaq revised this gist Mar 31, 2016. 3 changed files with 9 additions and 1 deletion.
    7 changes: 7 additions & 0 deletions SKI.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    const S = f => g => x => f(x)(g(x))
    const K = x => y => x

    const I = S(K)(K)
    const B = S(K(S))(K)
    const C = S(S(K(S(K(S))(K)))(S))(K(K))
    const W = S(S)(K(S(K)(K)))
    2 changes: 1 addition & 1 deletion combinators.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    const I = x => x;
    const K = x => _ => x;
    const K = x => y => x;
    const A = f => x => f(x);
    const T = x => f => f(x);
    const W = f => x => f(x)(x);
    1 change: 1 addition & 0 deletions references.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    [Collected Lambdas](http://jwodder.freeshell.org/lambda.html)
  27. @Avaq Avaq revised this gist Feb 18, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion combinators.md
    Original file line number Diff line number Diff line change
    @@ -13,5 +13,5 @@ fix-point\* | **Y** | fix | | `(a → a) → a`

    \* In JavaScript and other non-lazy languages, it is impossible to implement the
    Y-combinator. Instead a variant known as the *applicative* or *strict*
    fix-point combinator is implemented. This variant is commonly fererred to as
    fix-point combinator is implemented. This variant is commonly rererred to as
    the Z-combinator.
  28. @Avaq Avaq revised this gist Feb 18, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion combinators.md
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,6 @@ psi | **P** | on | | `(b → b → c) → (a → b) → a
    fix-point\* | **Y** | fix | | `(a → a) → a`

    \* In JavaScript and other non-lazy languages, it is impossible to implement the
    Fix-Point combinator. Instead a variant known as the *applicative* or *strict*
    Y-combinator. Instead a variant known as the *applicative* or *strict*
    fix-point combinator is implemented. This variant is commonly fererred to as
    the Z-combinator.
  29. @Avaq Avaq revised this gist Feb 18, 2016. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion combinators.md
    Original file line number Diff line number Diff line change
    @@ -13,4 +13,5 @@ fix-point\* | **Y** | fix | | `(a → a) → a`

    \* In JavaScript and other non-lazy languages, it is impossible to implement the
    Fix-Point combinator. Instead a variant known as the *applicative* or *strict*
    fix-point combinator, sometimes referred to as the Z-combinator.
    fix-point combinator is implemented. This variant is commonly fererred to as
    the Z-combinator.
  30. @Avaq Avaq revised this gist Feb 18, 2016. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion combinators.md
    Original file line number Diff line number Diff line change
    @@ -9,4 +9,8 @@ flip | **C** | flip | flip | `(a → b → c) → b → a → c`
    compose | **B** | (.) | compose | `(b → c) → (a → b) → a → c`
    substitution | **S** | | | `(a → b → c) → (a → b) → a → c`
    psi | **P** | on | | `(b → b → c) → (a → b) → a → a → c`
    fix-point | **Y** | fix | | `(a → a) → a`
    fix-point\* | **Y** | fix | | `(a → a) → a`

    \* In JavaScript and other non-lazy languages, it is impossible to implement the
    Fix-Point combinator. Instead a variant known as the *applicative* or *strict*
    fix-point combinator, sometimes referred to as the Z-combinator.