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': (n) => 0,
- 'one': (n) => 1,
- 'any': (n) => fib(n - 1) + fib(n - 2)
- });
- console.log(new Array(20).fill().map((x,i) => fib(i)));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement