1.2.1 • Published 6 years ago

y-combinator-node v1.2.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

y-combinator-node

y-combinator-node is an implementation of Y combinator in JavaScript for tail call optimization.

Examples

import { Y } from 'y-combinator-node';

const fibonacci = Y(fib => (n => (n <= 2 ? 1 : fib(n - 1) + fib(n - 2))))

console.log( fibonacci(10) )
// 55

const 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:

import { Y } from 'y-combinator-node';
// or
const { Y } = require('y-combinator-node');
1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

7 years ago

1.0.0

7 years ago