y-combinator-node
Y combinator for javascript
Last updated 3 years ago by andy*() .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install y-combinator-node 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.2.1                                ...           latest (3 years ago)

4 Versions

  • 1.2.1                                ...           3 years ago
  • 1.2.0                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 7
Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |