From b193674b4a1dce1b348489fa13dd42254b9a3ebb Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 17 Aug 2023 14:12:24 +0800 Subject: 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 --- runtime/lua/vim/_meta/vimfn.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'runtime/lua/vim') diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua index 4fe9093666..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"') --- 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 .. " <"') --- " 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 ---- |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 -- cgit