Previous CloneSet | Next CloneSet | Back to Main Report |
Clone Mass | Clones in CloneSet | Parameter Count | Clone Similarity | Syntax Category [Sequence Length] |
---|---|---|---|---|
13 | 2 | 2 | 0.984 | ExpressionStatement |
Clone Abstraction | Parameter Bindings |
Clone Instance (Click to see clone) | Line Count | Source Line | Source File |
---|---|---|---|
1 | 13 | 287 | Closure/closure/goog/array/array.js |
2 | 13 | 326 | Closure/closure/goog/array/array.js |
| ||||
/** * Passes every element of an array into a function and accumulates the result. * * See {@link http://tinyurl.com/developer-mozilla-org-array-reduce} * * For example: * var a = [1, 2, 3, 4]; * goog.array.reduce(a, function(r, v, i, arr) {return r + v;}, 0); * returns 10 * * @param {goog.array.ArrayLike} arr The array over which to iterate. * @param {Function} f The function to call for every element. This function * takes 4 arguments (the function's previous result or the initial value, * the value of the current array element, the current array index, and the * array itself) * function(previousValue, currentValue, index, array). * @param {*} val The initial value to pass into the function on the first call. * @param {Object=} opt_obj The object to be used as the value of 'this' * within f. * @return {*} Result of evaluating f repeatedly across the values of the array. */ goog.array.reduce= function (arr, f, val, opt_obj){ if (arr.reduce) { if (opt_obj) { return arr.reduce(goog.bind(f, opt_obj), val); } else { return arr.reduce(f, val); } } var rval= val; goog.array.forEach(arr, function (val, index){ rval= f.call(opt_obj, rval, val, index, arr); } ); return rval; } ; |
| ||||
/** * Passes every element of an array into a function and accumulates the result, * starting from the last element and working towards the first. * * See {@link http://tinyurl.com/developer-mozilla-org-array-reduceright} * * For example: * var a = ['a', 'b', 'c']; * goog.array.reduceRight(a, function(r, v, i, arr) {return r + v;}, ''); * returns 'cba' * * @param {goog.array.ArrayLike} arr The array over which to iterate. * @param {Function} f The function to call for every element. This function * takes 4 arguments (the function's previous result or the initial value, * the value of the current array element, the current array index, and the * array itself) * function(previousValue, currentValue, index, array). * @param {*} val The initial value to pass into the function on the first call. * @param {Object=} opt_obj The object to be used as the value of 'this' * within f. * @return {*} Object returned as a result of evaluating f repeatedly across the * values of the array. */ goog.array.reduceRight= function (arr, f, val, opt_obj){ if (arr.reduceRight) { if (opt_obj) { return arr.reduceRight(goog.bind(f, opt_obj), val); } else { return arr.reduceRight(f, val); } } var rval= val; goog.array.forEachRight(arr, function (val, index){ rval= f.call(opt_obj, rval, val, index, arr); } ); return rval; } ; |
| |||
/** * Passes every element of an array into a function and accumulates the result, * starting from the last element and working towards the first. * * See {@link http://tinyurl.com/developer-mozilla-org-array-reduceright} * * For example: * var a = ['a', 'b', 'c']; * goog.array.reduceRight(a, function(r, v, i, arr) {return r + v;}, ''); * returns 'cba' * * @param {goog.array.ArrayLike} arr The array over which to iterate. * @param {Function} f The function to call for every element. This function * takes 4 arguments (the function's previous result or the initial value, * the value of the current array element, the current array index, and the * array itself) * function(previousValue, currentValue, index, array). * @param {*} val The initial value to pass into the function on the first call. * @param {Object=} opt_obj The object to be used as the value of 'this' * within f. * @return {*} Object returned as a result of evaluating f repeatedly across the * values of the array. */ /** * Passes every element of an array into a function and accumulates the result. * * See {@link http://tinyurl.com/developer-mozilla-org-array-reduce} * * For example: * var a = [1, 2, 3, 4]; * goog.array.reduce(a, function(r, v, i, arr) {return r + v;}, 0); * returns 10 * * @param {goog.array.ArrayLike} arr The array over which to iterate. * @param {Function} f The function to call for every element. This function * takes 4 arguments (the function's previous result or the initial value, * the value of the current array element, the current array index, and the * array itself) * function(previousValue, currentValue, index, array). * @param {*} val The initial value to pass into the function on the first call. * @param {Object=} opt_obj The object to be used as the value of 'this' * within f. * @return {*} Result of evaluating f repeatedly across the values of the array. */ goog.array. [[#variable5d891b80]]= function (arr,f,val,opt_obj) { if (arr. [[#variable5d891b80]]) { if (opt_obj) { return arr. [[#variable5d891b80]](goog.bind(f,opt_obj),val); } else { return arr. [[#variable5d891b80]](f,val); } } var rval=val; goog.array. [[#variable5d891aa0]](arr, function (val,index) { rval=f.call(opt_obj,rval,val,index,arr); } ); return rval; } ; |
CloneAbstraction |
Parameter Index | Clone Instance | Parameter Name | Value |
---|---|---|---|
1 | 1 | [[#5d891b80]] | reduceRight |
1 | 2 | [[#5d891b80]] | reduce |
2 | 1 | [[#5d891aa0]] | forEachRight |
2 | 2 | [[#5d891aa0]] | forEach |