mirror of
https://github.com/neovim/neovim.git
synced 2025-09-16 16:28:17 +00:00
vim-patch:8.2.3848: cannot use reduce() for a string
Problem: Cannot use reduce() for a string.
Solution: Make reduce() work with a string. (Naruhiko Nishino, closes vim/vim#9366)
0ccb5842f5
Omit tv_get_first_char() as it doesn't really save much code.
Co-authored-by: rbtnn <naru123456789@gmail.com>
This commit is contained in:
7
runtime/doc/builtin.txt
generated
7
runtime/doc/builtin.txt
generated
@@ -5514,9 +5514,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 +5527,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()*
|
||||
|
7
runtime/lua/vim/_meta/vimfn.lua
generated
7
runtime/lua/vim/_meta/vimfn.lua
generated
@@ -6551,9 +6551,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 +6564,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
|
||||
|
Reference in New Issue
Block a user