code: function lazyProduct(sets, f, context){
          if (!context){
            context=this;
          }
  
          var p = [];
          var max = sets.length-1;
          var lens = [];
  
          for (var i=sets.length;i--;) {
            lens[i] = sets[i].length;
          }
  
          function dive(d){
            var a = sets[d];
            var len = lens[d];
  
            if (d === max) {
              for (var i=0;i<len;++i) {
                p[d] = a[i];
                f.apply(context, p);
              }
            } else {
              for (var i=0;i<len;++i) {
                p[d]=a[i];
                dive(d+1);
              }
            }
  
            p.pop();
          }
  
          dive(0);
        }
docs: sets: an array of arrays f: your callback function context: [optional] the `this` to use for your callback http://phrogz.net/lazy-cartesian-product