Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 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': function (n) { return 0 },
  15. 'one': function (n) { return 1 },
  16. 'any': function (n) { return fib(n - 1) + fib(n - 2); }
  17. });
  18.  
  19. document.body.innerHTML =
  20. new Array(20).fill().map(function (x,i) { return fib(i); });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement