{"_id":"y-combinator-js","_rev":"3-fedea04cde260e2330aa71201e7518d0","name":"y-combinator-js","description":"y-combinator-js","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"y-combinator-js","version":"1.0.0","description":"y-combinator-js","main":"index.js","scripts":{"demo":"node --harmony node_modules/.bin/ava demo.js --verbose --watch"},"repository":{"type":"git","url":"git+https://github.com/noob9527/y-combinator-js.git"},"author":{"name":"xy"},"license":"MIT","devDependencies":{"ava":"^0.18.1","chai":"^3.5.0"},"gitHead":"3b549751b0be8915e433b5c12195246d718cdfb0","bugs":{"url":"https://github.com/noob9527/y-combinator-js/issues"},"homepage":"https://github.com/noob9527/y-combinator-js#readme","_id":"y-combinator-js@1.0.0","_shasum":"3c560906cf18268d3452ece5c2a91dddfce4f8e1","_from":".","_npmVersion":"4.0.5","_nodeVersion":"7.4.0","_npmUser":{"name":"noob9527","email":"xy2061864@gmail.com"},"dist":{"shasum":"3c560906cf18268d3452ece5c2a91dddfce4f8e1","tarball":"https://registry.npmjs.org/y-combinator-js/-/y-combinator-js-1.0.0.tgz","integrity":"sha512-4su2F12jybuJt4LBTpNo+HqDFJtirY7KqX1griFgYUCtVM1+nz9dpHFpzei84LOI2nQcDTV153XPHD0ElOhZFg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIH/uAg9v4a6XaDhPkG18jB3XzZRdfUDQ99vmXzwW/AotAiEA3WEkKvdx7wdu00ZVVt9+ZeMu8xaUnvuntyMmWlSSzFo="}]},"maintainers":[{"name":"noob9527","email":"xy2061864@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/y-combinator-js-1.0.0.tgz_1487777641341_0.5418734112754464"}},"1.0.1":{"name":"y-combinator-js","version":"1.0.1","description":"y-combinator-js","main":"index.js","scripts":{"demo":"node --harmony node_modules/.bin/ava demo.js --verbose --watch"},"repository":{"type":"git","url":"git+https://github.com/noob9527/y-combinator-js.git"},"author":{"name":"xy"},"license":"MIT","devDependencies":{"ava":"^0.18.1","chai":"^3.5.0"},"gitHead":"b08ad14f96af65eadcad64f06412255553aa5162","bugs":{"url":"https://github.com/noob9527/y-combinator-js/issues"},"homepage":"https://github.com/noob9527/y-combinator-js#readme","_id":"y-combinator-js@1.0.1","_shasum":"8ceb1d931b7bc34528b3152e28dc7bfcdfc9440a","_from":".","_npmVersion":"4.0.5","_nodeVersion":"7.4.0","_npmUser":{"name":"noob9527","email":"xy2061864@gmail.com"},"dist":{"shasum":"8ceb1d931b7bc34528b3152e28dc7bfcdfc9440a","tarball":"https://registry.npmjs.org/y-combinator-js/-/y-combinator-js-1.0.1.tgz","integrity":"sha512-z+KjsrqFEfhkz/LsuZoOIs97zdLN9XAyFsJ2xeAet4LyAh2XdX9hpVIdppdqYwVlONNkUXOL0CQ/kyB5T/iUKQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEttw5vbhhm6IGxjYz3kfM07buZAgKrCb8+iiUihLjOQAiBctNRizUk3QxaRHJvgHVQ6OlaSSli3hayZHcXn/rU7LQ=="}]},"maintainers":[{"name":"noob9527","email":"xy2061864@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/y-combinator-js-1.0.1.tgz_1487778054814_0.900498149683699"}}},"readme":"# Y-COMBINATOR-JS\n> derive the y combinator using pure javascript\n\nThe Y combinator discovered by [Haskell B. Curry](https://en.wikipedia.org/wiki/Haskell_Curry) is an implementation of the fixed-point combinator in lambda calculus.It defined as:\n- call by value: `λf.(λx.f(λn.x x n))(λx.f(λn.x x n))`\n- call by name: `λf.(λx.f(x x))(λx.f(x x))`\n\nso in ecmascript 2015, It can be implement by one line\n```javascript\nf => (x => f(n => x(x)(n)))(x => f(n => x(x)(n)));\n``` \n\n### Installation\nusing npm\n```bash\nnpm install y-combinator-js\n```\n\n### Usage\nit won't decrease the computation complexity, so don't use it in production enviroment,unless you know what you do. \n```javascript\nimport Y from 'y-combinator-js';\n```\n\nthen enjoy it:\n- factorial\n    ```javascript\n    const FACT10 = 3628800;\n    const fact = Y(f => (n => n === 0 ? 1 : n * f(n - 1)));\n    fact(10).should.equal(FACT10);\n    ```\n\n- fibonacci\n    ```javascript\n    const FIB = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144];\n    const fibonacci = Y(fib => (n => (n <= 2 ? 1 : fib(n - 1) + fib(n - 2))));\n    fibonacci(5).should.equal(FIB[5]);\n    fibonacci(10).should.equal(FIB[10]);\n    ```\n\n### License\nMIT","maintainers":[{"name":"noob9527","email":"xy2061864@gmail.com"}],"time":{"modified":"2022-06-29T06:27:21.733Z","created":"2017-02-22T15:34:01.595Z","1.0.0":"2017-02-22T15:34:01.595Z","1.0.1":"2017-02-22T15:40:56.737Z"},"homepage":"https://github.com/noob9527/y-combinator-js#readme","repository":{"type":"git","url":"git+https://github.com/noob9527/y-combinator-js.git"},"author":{"name":"xy"},"bugs":{"url":"https://github.com/noob9527/y-combinator-js/issues"},"license":"MIT","readmeFilename":"README.md"}