version 0.3.3 is on the books -- with reduceRight

This commit is contained in:
Jeremy Ashkenas
2009-10-31 08:26:03 -04:00
parent cb38c6ae63
commit d4a5ed6a73
3 changed files with 15 additions and 7 deletions

View File

@@ -107,11 +107,11 @@
<p> <p>
<table> <table>
<tr> <tr>
<td><a href="underscore.js">Development Version (0.3.2)</a></td> <td><a href="underscore.js">Development Version (0.3.3)</a></td>
<td><i>16kb, Uncompressed with Comments</i></td> <td><i>16kb, Uncompressed with Comments</i></td>
</tr> </tr>
<tr> <tr>
<td><a href="underscore-min.js">Production Version (0.3.2)</a></td> <td><a href="underscore-min.js">Production Version (0.3.3)</a></td>
<td><i>4kb, Packed and Gzipped</i></td> <td><i>4kb, Packed and Gzipped</i></td>
</tr> </tr>
</table> </table>
@@ -216,7 +216,9 @@ var sum = _.reduce([1, 2, 3], 0, function(memo, num){ return memo + num });
<span class="alias">Alias: <b>foldr</b></span> <span class="alias">Alias: <b>foldr</b></span>
<br /> <br />
The right-associative version of <b>reduce</b>. Delegates to the The right-associative version of <b>reduce</b>. Delegates to the
JavaScript 1.8 version of <b>reduceRight</b>, if it exists. JavaScript 1.8 version of <b>reduceRight</b>, if it exists. <b>Foldr</b>
is not as useful in JavaScript as it would be in a language with lazy
evaluation.
</p> </p>
<pre> <pre>
var list = [[0, 1], [2, 3], [4, 5]]; var list = [[0, 1], [2, 3], [4, 5]];
@@ -229,8 +231,8 @@ var flat = _.reduceRight(list, [], function(a, b) { return a.concat(b); });
<br /> <br />
Looks through each value in the <b>list</b>, returning the first one that Looks through each value in the <b>list</b>, returning the first one that
passes a truth test (<b>iterator</b>). The function returns as passes a truth test (<b>iterator</b>). The function returns as
soon as it finds the first acceptable element, and doesn't continue to soon as it finds an acceptable element, and doesn't traverse the
traverse the list. entire list.
</p> </p>
<pre> <pre>
var even = _.detect([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; }); var even = _.detect([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
@@ -767,6 +769,12 @@ _.template(list, {people : ['moe', 'curly', 'larry']});
<h2>Change Log</h2> <h2>Change Log</h2>
<p>
<b class="header">0.3.3</b><br />
Added the JavaScript 1.8 function <tt>reduceRight</tt>. Aliased it
as <tt>foldr</tt>, and aliased <tt>reduce</tt> as <tt>foldl</tt>.
</p>
<p> <p>
<b class="header">0.3.2</b><br /> <b class="header">0.3.2</b><br />
Now runs on stock <a href="http://www.mozilla.org/rhino/">Rhino</a> Now runs on stock <a href="http://www.mozilla.org/rhino/">Rhino</a>

2
underscore-min.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -23,7 +23,7 @@
if (typeof exports !== 'undefined') _ = exports; if (typeof exports !== 'undefined') _ = exports;
// Current version. // Current version.
_.VERSION = '0.3.2'; _.VERSION = '0.3.3';
/*------------------------ Collection Functions: ---------------------------*/ /*------------------------ Collection Functions: ---------------------------*/