aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-08-17 14:12:24 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-08-17 15:37:32 +0800
commitb193674b4a1dce1b348489fa13dd42254b9a3ebb (patch)
tree0f2ba228c173892c16b082236f0eb124ad02fab8 /src/nvim/eval.lua
parentc5576fcc8003280489c0aa0323a966e6de33e31f (diff)
downloadrneovim-b193674b4a1dce1b348489fa13dd42254b9a3ebb.tar.gz
rneovim-b193674b4a1dce1b348489fa13dd42254b9a3ebb.tar.bz2
rneovim-b193674b4a1dce1b348489fa13dd42254b9a3ebb.zip
vim-patch:partial:8.2.3849: functions implementing reduce and map are too long
Problem: Functions implementing reduce and map are too long. Solution: Use a function for each type of value. Add a few more test cases and add to the help. (Yegappan Lakshmanan, closes vim/vim#9370) https://github.com/vim/vim/commit/389b72196e6aaeafe3f907c73d271f2c6b931140 Partial port as this doesn't include handling for non-materialized List. Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/nvim/eval.lua')
-rw-r--r--src/nvim/eval.lua13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua
index 62d97a2931..f8ba16365a 100644
--- a/src/nvim/eval.lua
+++ b/src/nvim/eval.lua
@@ -2551,8 +2551,8 @@ M.funcs = {
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
@@ -6068,7 +6068,8 @@ M.funcs = {
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".
@@ -7876,9 +7877,9 @@ M.funcs = {
tags = { 'E998' },
desc = [=[
{func} is called for every item in {object}, which can be a
- |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.
+ |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