Permalink
Browse files

take works

  • Loading branch information...
1 parent 088177e commit cee5489463a7e40ae8a6890edb92799f072852e0 @substack committed Jul 10, 2011
Showing with 17 additions and 2 deletions.
  1. +17 −2 index.js
View
@@ -13,8 +13,8 @@ var mr = module.exports = function () {
colors.push(mr.fromIndex(i));
colors.push(mr.fromIndex(j));
- ranges.push([ i + dx / 2, j ]);
- ranges.push([ j + dx / 2, max ]);
+ ranges.push([ Math.floor(i + dx / 2), j ]);
+ ranges.push([ Math.floor(j + dx / 2), max ]);
}
return (function next () {
@@ -55,3 +55,18 @@ mr.fromIndex = function (i) {
}
};
};
+
+mr.take = function (n) {
+ if (n <= 0) return [];
+
+ var res = [];
+ var c = { next : mr };
+
+ for (var i = 0; i < n; i++) {
+ var c_ = c;
+ c = c.next();
+ res.push(c);
+ }
+
+ return res;
+};

0 comments on commit cee5489

Please sign in to comment.