Javascript Array foldRight(funcall,initial)

Description

Javascript Array foldRight(funcall,initial)


Array.prototype.foldRight = function(funcall,initial) {
    var i, result = initial;
    for(i = this.length; i > 0; i--) {
        result = funcall(this[i-1], result);
    }//  w  ww  .j  a  va2s  .c o  m
    return result;
};



PreviousNext

Related