Advertisement
alexxmde

Untitled

Apr 19th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function tuple (a, b) {
  2.   return function (i) {
  3.     if (i === 0) return a;
  4.     if (i === 1) return b;
  5.   }
  6. }
  7.  
  8. function car (t) {
  9.   return t(0);
  10. }
  11.  
  12. function cdr (t) {
  13.   return t(1);
  14. }
  15.  
  16. const me = tuple('alex', 'alonso');
  17.  
  18. const firstName = car(me);
  19. const lastName = cdr(me);
  20.  
  21. console.log(firstName + ' ' + lastName);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement