Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/therealklanni/ycomb
The almighty Y-combinator
https://github.com/therealklanni/ycomb
Last synced: 2 days ago
JSON representation
The almighty Y-combinator
- Host: GitHub
- URL: https://github.com/therealklanni/ycomb
- Owner: therealklanni
- Created: 2015-08-11T03:30:01.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-08-12T05:44:59.000Z (over 9 years ago)
- Last Synced: 2024-11-14T09:29:06.315Z (6 days ago)
- Language: JavaScript
- Homepage: https://medium.com/@therealklanni/the-mysterious-y-combinator-e824bebf8c96
- Size: 113 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Y-combinator
The Y-combinator can be used to create functions that behave recursively.
```js
// recursive factorial
let fact = n => n <= 1 ? n : n * fact(n - 1)// factorial using the Y-combinator
let fact = Y(f => n => n <= 1 ? n : n * f(n - 1))
```> **Read more about the Y-combinator in [The Mysterious Y-combinator](https://medium.com/@therealklanni/the-mysterious-y-combinator-e824bebf8c96)**
## Install
```
npm install --save ycomb
```## Use
```js
import Y from 'ycomb'
```Pass a function to `Y` that takes a function argument. Call the function argument if you want to recurse.
For an example, check out [Yl](https://github.com/therealklanni/yl), a function that behaves like a `while` loop (with some added benefits like currying, and return values).
## License
MIT © Kevin Lanni