Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Yonaba/Moses.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYonaba <roland.yonaba@gmail.com>2017-04-27 17:16:10 +0300
committerYonaba <roland.yonaba@gmail.com>2017-04-27 17:16:52 +0300
commit997ec36d8ac9f7167f1b0e69ec308536769e2f2b (patch)
tree81cf97b60f72ec2c65c1a9938b2a2d10ad061936 /moses.lua
parent590c069c44a343c7eca2ddd939d27250397dc008 (diff)
Added _.array
Fixed proper name of _.iterator in docs
Diffstat (limited to 'moses.lua')
-rw-r--r--moses.lua16
1 files changed, 13 insertions, 3 deletions
diff --git a/moses.lua b/moses.lua
index 0f2b641..9dd93c1 100644
--- a/moses.lua
+++ b/moses.lua
@@ -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