aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/builtin.txt14
-rw-r--r--runtime/lua/vim/_meta/vimfn.lua14
2 files changed, 16 insertions, 12 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index 0b24ed8d85..4b617763da 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -1635,8 +1635,8 @@ filter({expr1}, {expr2}) *filter()*
of the current item. For a |Dictionary| |v:key| has the key
of the current item and for a |List| |v:key| has the index of
the current item. For a |Blob| |v:key| has the index of the
- current byte.
-
+ current byte. For a |String| |v:key| has the index of the
+ current character.
Examples: >vim
call filter(mylist, 'v:val !~ "OLD"')
< Removes the items where "OLD" appears. >vim
@@ -4080,7 +4080,8 @@ map({expr1}, {expr2}) *map()*
of the current item. For a |Dictionary| |v:key| has the key
of the current item and for a |List| |v:key| has the index of
the current item. For a |Blob| |v:key| has the index of the
- current byte.
+ current byte. For a |String| |v:key| has the index of the
+ current character.
Example: >vim
call map(mylist, '"> " .. v:val .. " <"')
< This puts "> " before and " <" after each item in "mylist".
@@ -5514,9 +5515,9 @@ readfile({fname} [, {type} [, {max}]]) *readfile()*
reduce({object}, {func} [, {initial}]) *reduce()* *E998*
{func} is called for every item in {object}, which can be a
- |List| or a |Blob|. {func} is called with two arguments: the
- result so far and current item. After processing all items
- the result is returned.
+ |String|, |List| or a |Blob|. {func} is called with two
+ arguments: the result so far and current item. After
+ processing all items the result is returned.
{initial} is the initial result. When omitted, the first item
in {object} is used and {func} is first called for the second
@@ -5527,6 +5528,7 @@ reduce({object}, {func} [, {initial}]) *reduce()* *E99
echo reduce([1, 3, 5], { acc, val -> acc + val })
echo reduce(['x', 'y'], { acc, val -> acc .. val }, 'a')
echo reduce(0z1122, { acc, val -> 2 * acc + val })
+ echo reduce('xyz', { acc, val -> acc .. ',' .. val })
<
reg_executing() *reg_executing()*
diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua
index 4b90a9e3c0..17eda634e0 100644
--- a/runtime/lua/vim/_meta/vimfn.lua
+++ b/runtime/lua/vim/_meta/vimfn.lua
@@ -2017,8 +2017,8 @@ function vim.fn.filewritable(file) end
--- of the current item. For a |Dictionary| |v:key| has the key
--- of the current item and for a |List| |v:key| has the index of
--- the current item. For a |Blob| |v:key| has the index of the
---- current byte.
----
+--- current byte. For a |String| |v:key| has the index of the
+--- current character.
--- Examples: >vim
--- call filter(mylist, 'v:val !~ "OLD"')
--- <Removes the items where "OLD" appears. >vim
@@ -4937,7 +4937,8 @@ function vim.fn.log10(expr) end
--- of the current item. For a |Dictionary| |v:key| has the key
--- of the current item and for a |List| |v:key| has the index of
--- the current item. For a |Blob| |v:key| has the index of the
---- current byte.
+--- current byte. For a |String| |v:key| has the index of the
+--- current character.
--- Example: >vim
--- call map(mylist, '"> " .. v:val .. " <"')
--- <This puts "> " before and " <" after each item in "mylist".
@@ -6551,9 +6552,9 @@ function vim.fn.readdir(directory, expr) end
function vim.fn.readfile(fname, type, max) end
--- {func} is called for every item in {object}, which can be a
---- |List| or a |Blob|. {func} is called with two arguments: the
---- result so far and current item. After processing all items
---- the result is returned.
+--- |String|, |List| or a |Blob|. {func} is called with two
+--- arguments: the result so far and current item. After
+--- processing all items the result is returned.
---
--- {initial} is the initial result. When omitted, the first item
--- in {object} is used and {func} is first called for the second
@@ -6564,6 +6565,7 @@ function vim.fn.readfile(fname, type, max) end
--- echo reduce([1, 3, 5], { acc, val -> acc + val })
--- echo reduce(['x', 'y'], { acc, val -> acc .. val }, 'a')
--- echo reduce(0z1122, { acc, val -> 2 * acc + val })
+--- echo reduce('xyz', { acc, val -> acc .. ',' .. val })
--- <
---
--- @param object any