diff options
author | Yonaba <roland.yonaba@gmail.com> | 2017-04-27 17:16:10 +0300 |
---|---|---|
committer | Yonaba <roland.yonaba@gmail.com> | 2017-04-27 17:16:52 +0300 |
commit | 997ec36d8ac9f7167f1b0e69ec308536769e2f2b (patch) | |
tree | 81cf97b60f72ec2c65c1a9938b2a2d10ad061936 /moses.lua | |
parent | 590c069c44a343c7eca2ddd939d27250397dc008 (diff) |
Added _.array
Fixed proper name of _.iterator in docs
Diffstat (limited to 'moses.lua')
-rw-r--r-- | moses.lua | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -2,10 +2,10 @@ -- @author [Roland Yonaba](http://github.com/Yonaba) -- @copyright 2012-2017 -- @license [MIT](http://www.opensource.org/licenses/mit-license.php) --- @release 1.6.0 +-- @release 1.6.1 -- @module moses -local _MODULEVERSION = '1.6.0' +local _MODULEVERSION = '1.6.1' -- Internalisation local next, type, select, pcall = next, type, select, pcall @@ -1498,7 +1498,7 @@ end --- Produces an iterator which repeatedly apply a function `f` onto an input. -- Yields x, then f(x), then f(f(x)), continuously. --- @name iterate +-- @name iterator -- @param f a function -- @param x an initial input to `f` -- @return an iterator fnction @@ -1510,6 +1510,16 @@ function _.iterator(f, x) end end +--- Iterates an iterator and returns its values in an array. +-- @name array +-- @param ... an iterator (a function, a table and a value) +-- @return an array of results +function _.array(...) + local r = {} + for v in ... do r[#r+1] = v end + return r +end + --- Creates a function of `f` with arguments flipped in reverse order. -- @name flip -- @param f a function |