Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var typed = require("typed-function");
- typed.addType({
- name: 'zero',
- test: function (x) { return x === 0; }
- });
- typed.addType({
- name: 'one',
- test: function (x) { return x === 1; }
- });
- const fib = typed({
- 'zero': function (n) { return 0 },
- 'one': function (n) { return 1 },
- 'any': function (n) { return fib(n - 1) + fib(n - 2); }
- });
- document.body.innerHTML =
- new Array(20).fill().map(function (x,i) { return fib(i); });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement