summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2021-12-19 10:35:15 +0000
committerBram Moolenaar <Bram@vim.org>2021-12-19 10:35:15 +0000
commit389b72196e6aaeafe3f907c73d271f2c6b931140 (patch)
tree4afb251968ba13c94cc8cbaa8daf7cf8a3279518 /runtime
parent0ccb5842f5fb103763d106c7aa364d758343c35a (diff)
patch 8.2.3849: functions implementing reduce and map are too longv8.2.3849
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 #9370)
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/eval.txt12
1 files changed, 7 insertions, 5 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index d54523f965..db8e1002dc 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -4893,7 +4893,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: >
call filter(mylist, 'v:val !~ "OLD"')
< Removes the items where "OLD" appears. >
@@ -7588,7 +7589,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: >
:call map(mylist, '"> " . v:val . " <"')
< This puts "> " before and " <" after each item in "mylist".
@@ -8959,9 +8961,9 @@ readfile({fname} [, {type} [, {max}]])
reduce({object}, {func} [, {initial}]) *reduce()* *E998*
{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