Skip to content

Commit

Permalink
and for foldr too
Browse files Browse the repository at this point in the history
  • Loading branch information
refractalize committed Mar 22, 2011
1 parent 161dcbf commit c373153
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions zo.js
Expand Up @@ -60,17 +60,19 @@ var zo = function (items, pipeline) {

var foldr = function (first, folder) {
pipeline.push(function (items, next) {
var xyz = function (foldedResult, index, items, next) {
var fold = function (foldedResult, index, items, next) {
if (index < 0) {
next(foldedResult);
} else {
folder(foldedResult, items[index], function (folded) {
xyz(folded, index - 1, items, next);
process.nextTick(function () {
fold(folded, index - 1, items, next);
});
});
}
};

xyz(first, items.length - 1, items, next);
fold(first, items.length - 1, items, next);
});
return zo(items, pipeline);
};
Expand Down

0 comments on commit c373153

Please sign in to comment.