summaryrefslogtreecommitdiff
path: root/Data/DefaultContent/Libraries/luafun/doc/transformations.rst
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-11-15 11:54:17 +0800
committerchai <chaifix@163.com>2021-11-15 11:54:17 +0800
commit30f2f46474bf4eda5f10d4c64a07cde01d469f66 (patch)
tree6ff2ed3262037b3c9bae2d2b9059a1d65773f31c /Data/DefaultContent/Libraries/luafun/doc/transformations.rst
parent4c36bed53fe63ae6056730b3ecad2573f03d88f8 (diff)
*rename DefaultContent -> BuiltIn
Diffstat (limited to 'Data/DefaultContent/Libraries/luafun/doc/transformations.rst')
-rw-r--r--Data/DefaultContent/Libraries/luafun/doc/transformations.rst87
1 files changed, 0 insertions, 87 deletions
diff --git a/Data/DefaultContent/Libraries/luafun/doc/transformations.rst b/Data/DefaultContent/Libraries/luafun/doc/transformations.rst
deleted file mode 100644
index e446d2f..0000000
--- a/Data/DefaultContent/Libraries/luafun/doc/transformations.rst
+++ /dev/null
@@ -1,87 +0,0 @@
-Transformations
-===============
-
-.. module:: fun
-
-.. function:: map(fun, gen, param, state)
- iterator:map(fun)
-
- :param fun: a function to apply
- :type fun: (function(...) -> ...)
- :returns: a new iterator
-
- Return a new iterator by applying the **fun** to each element of
- ``gen, param, state`` iterator. The mapping is performed on the fly
- and no values are buffered.
-
- Examples:
-
- .. code-block:: lua
-
- > each(print, map(function(x) return 2 * x end, range(4)))
- 2
- 4
- 6
- 8
-
- fun = function(...) return 'map', ... end
- > each(print, map(fun, range(4)))
- map 1
- map 2
- map 3
- map 4
-
-.. function:: enumerate(gen, param, state)
- iterator:enumerate()
-
- :returns: a new iterator
-
- Return a new iterator by enumerating all elements of the
- ``gen, param, state`` iterator starting from ``1``. The mapping is performed
- on the fly and no values are buffered.
-
- Examples:
-
- .. code-block:: lua
-
- > each(print, enumerate({"a", "b", "c", "d", "e"}))
- 1 a
- 2 b
- 3 c
- 4 d
- 5 e
-
- > each(print, enumerate(zip({"one", "two", "three", "four", "five"},
- {"a", "b", "c", "d", "e"})))
- 1 one a
- 2 two b
- 3 three c
- 4 four d
- 5 five e
-
-.. function:: intersperse(x, gen, param, state)
- iterator:intersperse(x)
-
- :type x: any
- :returns: a new iterator
-
- Return a new iterator where the **x** value is interspersed between the
- elements of the source iterator. The **x** value can also be added as a
- last element of returning iterator if the source iterator contains the odd
- number of elements.
-
- Examples:
-
- .. code-block:: lua
-
- > each(print, intersperse("x", {"a", "b", "c", "d", "e"}))
- a
- x
- b
- x
- c
- x
- d
- x
- e
- x