Skip to content

Commit

Permalink
Bump to 1.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonaba committed Apr 13, 2017
1 parent c50a23b commit 4725185
Show file tree
Hide file tree
Showing 9 changed files with 359 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Version history

## 1.5.1 (04/13/17)

* Added `_.curry`
* Added `_.fill`
* Added `.transpose` as an alias to `_.zip`

## 1.5.0 (04/10/17)

#### Additions
Expand Down
90 changes: 88 additions & 2 deletions doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ <h1>Module <code>moses</code></h1>
<h3>Info:</h3>
<ul>
<li><strong>Copyright</strong>: 2012-2017</li>
<li><strong>Release</strong>: 1.5.0</li>
<li><strong>Release</strong>: 1.6.0</li>
<li><strong>License</strong>: <a href="http://www.opensource.org/licenses/mit-license.php">MIT</a></li>
<li><strong>Author</strong>: <a href="http://github.com/Yonaba">Roland Yonaba</a></li>
</ul>
Expand Down Expand Up @@ -216,6 +216,10 @@ <h2><a href="#Array_functions">Array functions </a></h2>
<td class="summary">Returns an array where values are in reverse order.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#fill">fill (array, value[, i[, j]])</a></td>
<td class="summary">Replaces elements in a given array with a given value.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#selectWhile">selectWhile (array, f[, ...])</a></td>
<td class="summary">Collects values from a given array.</td>
</tr>
Expand Down Expand Up @@ -446,6 +450,10 @@ <h2><a href="#Utility_functions">Utility functions </a></h2>
<td class="name" nowrap><a href="#partial">partial (f, ...)</a></td>
<td class="summary">Partially apply a function by filling in any number of its arguments.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#curry">curry (f[, n_args])</a></td>
<td class="summary">Curries a function.</td>
</tr>
</table>
<h2><a href="#Object_functions">Object functions </a></h2>
<table class="function_list">
Expand Down Expand Up @@ -1851,6 +1859,44 @@ <h3>Returns:</h3>



</dd>
<dt>
<a name = "fill"></a>
<strong>fill (array, value[, i[, j]])</strong>
</dt>
<dd>
Replaces elements in a given array with a given value. In case <code>i</code> and <code>j</code> are given
it will only replaces values at indexes between <code>[i,j]</code>. In case <code>j</code> is greather than the array
size, it will append new values, increasing the array.


<h3>Parameters:</h3>
<ul>
<li><span class="parameter">array</span>
an array
</li>
<li><span class="parameter">value</span>
a value
</li>
<li><span class="parameter">i</span>
the index from which to start replacing values. Defaults to 1.
(<em>optional</em>)
</li>
<li><span class="parameter">j</span>
the index where to stop replacing values. Defaults to the array size.
(<em>optional</em>)
</li>
</ul>

<h3>Returns:</h3>
<ol>

the original array with values changed
</ol>




</dd>
<dt>
<a name = "selectWhile"></a>
Expand Down Expand Up @@ -2794,6 +2840,7 @@ <h3>See also:</h3>
<dd>
Merges values of each of the passed-in arrays in subsets.
Only values indexed with the same key in the given arrays are merged in the same subset.
<br/><em>Aliased as <code>transpose</code></em>


<h3>Parameters:</h3>
Expand Down Expand Up @@ -3690,6 +3737,45 @@ <h3>Returns:</h3>
</ol>


<h3>See also:</h3>
<ul>
<a href="index.html#curry">curry</a>
</ul>


</dd>
<dt>
<a name = "curry"></a>
<strong>curry (f[, n_args])</strong>
</dt>
<dd>
Curries a function. If the given function <code>f</code> takes multiple arguments, it returns another version of
<code>f</code> that takes a single argument (the first of the arguments to the original function) and returns a new
function that takes the remainder of the arguments and returns the result.


<h3>Parameters:</h3>
<ul>
<li><span class="parameter">f</span>
a function
</li>
<li><span class="parameter">n_args</span>
the number of arguments expected for <code>f</code>. Defaults to 2.
(<em>optional</em>)
</li>
</ul>

<h3>Returns:</h3>
<ol>

a curried version of <code>f</code>
</ol>


<h3>See also:</h3>
<ul>
<a href="index.html#partial">partial</a>
</ul>


</dd>
Expand Down Expand Up @@ -4582,7 +4668,7 @@ <h3>Returns:</h3>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2017-04-10 13:53:08 </i>
<i style="float:right;">Last updated 2017-04-13 10:53:51 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
Expand Down
62 changes: 61 additions & 1 deletion doc/topics/tutorial.md.html
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,40 @@ <h3>reverse (array)</h3>
</pre>


<h3>fill (array, value, i, j)</h3>

<p>Replaces all elements in a given array with a given value.</p>

<pre>
<span class="keyword">local</span> array = _.range(<span class="number">1</span>,<span class="number">5</span>)
_.fill(array, <span class="number">0</span>) <span class="comment">-- =&gt; {0,0,0,0,0}</span>
</pre>


<p>It can start replacing value at a specific index.</p>

<pre>
<span class="keyword">local</span> array = _.range(<span class="number">1</span>,<span class="number">5</span>)
_.fill(array,<span class="number">0</span>,<span class="number">3</span>) <span class="comment">-- =&gt; {1,2,0,0,0}</span>
</pre>


<p>It can replace only values within a specific range.</p>

<pre>
<span class="keyword">local</span> array = _.range(<span class="number">1</span>,<span class="number">5</span>)
_.fill(array,<span class="number">0</span>,<span class="number">2</span>,<span class="number">4</span>) <span class="comment">-- =&gt; {1,0,0,0,5}</span>
</pre>


<p>In case the upper bound index i greather than the array size, it will enlarge the array.</p>

<pre>
<span class="keyword">local</span> array = _.range(<span class="number">1</span>,<span class="number">5</span>)
_.fill(array,<span class="number">0</span>,<span class="number">5</span>,<span class="number">10</span>) <span class="comment">-- =&gt; {1,2,3,4,0,0,0,0,0,0}</span>
</pre>


<h3>selectWhile (array, f, &hellip;</h3>

<p><em>Aliases: <code>_.takeWhile</code></em>.</p>
Expand Down Expand Up @@ -1170,6 +1204,8 @@ <h3>isunique (array)</h3>

<h3>zip (&hellip;)</h3>

<p><em>Aliases: <code>_.transpose</code></em>.</p>

<p>Zips values from different arrays, on the basis on their common keys.</p>

<pre>
Expand Down Expand Up @@ -1629,6 +1665,30 @@ <h3>partial (f, &hellip;)</h3>
</pre>


<h3>curry (f, n_args)</h3>

<p>Curries a function. If the given function <code>f</code> takes multiple arguments, it returns another version of <code>f</code> that takes a single argument
(the first of the arguments to the original function) and returns a new function that takes the remainder of the arguments and returns the result.</p>

<pre>
<span class="keyword">local</span> <span class="keyword">function</span> sumOf3args(x,y,z) <span class="keyword">return</span> x + y + z <span class="keyword">end</span>
<span class="keyword">local</span> curried_sumOf3args = _.curry(sumOf3args, <span class="number">3</span>)
sumOf3args(<span class="number">1</span>)(<span class="number">2</span>)(<span class="number">3</span>)) <span class="comment">-- =&gt; 6
</span>sumOf3args(<span class="number">0</span>)(<span class="number">6</span>)(<span class="number">9</span>)) <span class="comment">-- =&gt; 15</span>
</pre>


<p><code>n_args</code> defaults to 2.</p>

<pre>
<span class="keyword">local</span> <span class="keyword">function</span> product(x,y) <span class="keyword">return</span> x * y <span class="keyword">end</span>
<span class="keyword">local</span> curried_product = _.curry(product)
curried_product(<span class="number">5</span>)(<span class="number">4</span>) <span class="comment">-- =&gt; 20
</span>curried_product(<span class="number">3</span>)(-<span class="number">5</span>) <span class="comment">-- =&gt; -15
</span>curried_product(<span class="number">0</span>)(<span class="number">1</span>) <span class="comment">-- =&gt; 0</span>
</pre>


<p><strong><a href="#TOC">[⬆]</a></strong></p>

<p><a name="_a_name__object__Object_functions__a_"></a></p>
Expand Down Expand Up @@ -2073,7 +2133,7 @@ <h2><a name='import'>Import</a></h2>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2017-04-10 13:53:08 </i>
<i style="float:right;">Last updated 2017-04-13 10:53:51 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
Expand Down
53 changes: 53 additions & 0 deletions doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,36 @@ Reverses an array.
_.reverse({1,2,3,'d'}) -- => "{'d',3,2,1}"
````

### fill (array, value, i, j)

Replaces all elements in a given array with a given value.

```lua
local array = _.range(1,5)
_.fill(array, 0) -- => {0,0,0,0,0}
````

It can start replacing value at a specific index.

```lua
local array = _.range(1,5)
_.fill(array,0,3) -- => {1,2,0,0,0}
````

It can replace only values within a specific range.

```lua
local array = _.range(1,5)
_.fill(array,0,2,4) -- => {1,0,0,0,5}
````

In case the upper bound index i greather than the array size, it will enlarge the array.

```lua
local array = _.range(1,5)
_.fill(array,0,5,10) -- => {1,2,3,4,0,0,0,0,0,0}
````

### selectWhile (array, f, ...
*Aliases: `_.takeWhile`*.

Expand Down Expand Up @@ -991,6 +1021,7 @@ _.isunique({1,2,3,4,4}) -- => false
````

### zip (...)
*Aliases: `_.transpose`*.

Zips values from different arrays, on the basis on their common keys.

Expand Down Expand Up @@ -1405,6 +1436,28 @@ local remove5 = _.partial(diff, '_', 5) -- arg 'a' will be given at call-time, b
remove5(20) -- => 15
````

### curry (f, n_args)

Curries a function. If the given function `f` takes multiple arguments, it returns another version of `f` that takes a single argument
(the first of the arguments to the original function) and returns a new function that takes the remainder of the arguments and returns the result.

```lua
local function sumOf3args(x,y,z) return x + y + z end
local curried_sumOf3args = _.curry(sumOf3args, 3)
sumOf3args(1)(2)(3)) -- => 6
sumOf3args(0)(6)(9)) -- => 15
````

`n_args` defaults to 2.

```lua
local function product(x,y) return x * y end
local curried_product = _.curry(product)
curried_product(5)(4) -- => 20
curried_product(3)(-5) -- => -15
curried_product(0)(1) -- => 0
````

**[[]](#TOC)**

## <a name='object'>Object functions</a>
Expand Down
Loading

0 comments on commit 4725185

Please sign in to comment.