https://github.com/andy2046/y-combinator-node
implementation of Y combinator in JavaScript for tail call optimization
https://github.com/andy2046/y-combinator-node
javascript node tail-call-optimization tco y-combinator
Last synced: 7 months ago
JSON representation
implementation of Y combinator in JavaScript for tail call optimization
- Host: GitHub
- URL: https://github.com/andy2046/y-combinator-node
- Owner: andy2046
- License: mit
- Created: 2017-11-02T02:36:33.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-14T05:09:10.000Z (over 7 years ago)
- Last Synced: 2025-03-04T22:37:16.453Z (7 months ago)
- Topics: javascript, node, tail-call-optimization, tco, y-combinator
- Language: JavaScript
- Homepage:
- Size: 122 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# y-combinator-node
y-combinator-node is an implementation of **Y combinator** in JavaScript for tail call optimization.## Examples
```js
import { Y } from 'y-combinator-node';const fibonacci = Y(fib => (n => (n <= 2 ? 1 : fib(n - 1) + fib(n - 2))))
console.log( fibonacci(10) )
// 55const factorial = Y(f => (n => n === 0 ? 1 : n * f(n - 1)))
console.log( factorial(10) )
// 3628800```
## Installation
```
npm install --save y-combinator-node
```## Usage
You can import from `y-combinator-node`:```js
import { Y } from 'y-combinator-node';
// or
const { Y } = require('y-combinator-node');
```