Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. var typed = require("typed-function");
  2.  
  3. typed.addType({
  4. name: 'zero',
  5. test: function (x) { return x === 0; }
  6. });
  7.  
  8. typed.addType({
  9. name: 'one',
  10. test: function (x) { return x === 1; }
  11. });
  12.  
  13. const fib = typed({
  14. 'zero': (n) => 0,
  15. 'one': (n) => 1,
  16. 'any': (n) => fib(n - 1) + fib(n - 2)
  17. });
  18.  
  19. console.log(new Array(20).fill().map((x,i) => fib(i)));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement