Mercurial > vim
comparison runtime/doc/eval.txt @ 20649:1fa0ace0ba65 v8.2.0878
patch 8.2.0878: no reduce() function
Commit: https://github.com/vim/vim/commit/85629985b71035608a37ba3bde86968481490d46
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jun 1 18:39:20 2020 +0200
patch 8.2.0878: no reduce() function
Problem: No reduce() function.
Solution: Add a reduce() function. (closes https://github.com/vim/vim/issues/5481)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 01 Jun 2020 18:45:03 +0200 |
parents | 8a2b86a39ef4 |
children | 6ff992bf4c82 |
comparison
equal
deleted
inserted
replaced
20648:78db823f74d0 | 20649:1fa0ace0ba65 |
---|---|
2677 List items from {expr} to {max} | 2677 List items from {expr} to {max} |
2678 readdir({dir} [, {expr}]) List file names in {dir} selected by {expr} | 2678 readdir({dir} [, {expr}]) List file names in {dir} selected by {expr} |
2679 readdirex({dir} [, {expr}]) List file info in {dir} selected by {expr} | 2679 readdirex({dir} [, {expr}]) List file info in {dir} selected by {expr} |
2680 readfile({fname} [, {type} [, {max}]]) | 2680 readfile({fname} [, {type} [, {max}]]) |
2681 List get list of lines from file {fname} | 2681 List get list of lines from file {fname} |
2682 reduce({object}, {func} [, {initial}]) | |
2683 any reduce {object} using {func} | |
2682 reg_executing() String get the executing register name | 2684 reg_executing() String get the executing register name |
2683 reg_recording() String get the recording register name | 2685 reg_recording() String get the recording register name |
2684 reltime([{start} [, {end}]]) List get time value | 2686 reltime([{start} [, {end}]]) List get time value |
2685 reltimefloat({time}) Float turn the time value into a Float | 2687 reltimefloat({time}) Float turn the time value into a Float |
2686 reltimestr({time}) String turn time value into a String | 2688 reltimestr({time}) String turn time value into a String |
7963 Also see |writefile()|. | 7965 Also see |writefile()|. |
7964 | 7966 |
7965 Can also be used as a |method|: > | 7967 Can also be used as a |method|: > |
7966 GetFileName()->readfile() | 7968 GetFileName()->readfile() |
7967 | 7969 |
7970 reduce({object}, {func} [, {initial}]) *reduce()* *E998* | |
7971 {func} is called for every item in {object}, which can be a | |
7972 |List| or a |Blob|. {func} is called with two arguments: the | |
7973 result so far and current item. After processing all items | |
7974 the result is returned. | |
7975 | |
7976 {initial} is the initial result. When omitted, the first item | |
7977 in {object} is used and {func} is first called for the second | |
7978 item. If {initial} is not given and {object} is empty no | |
7979 result can be computed, an E998 error is given. | |
7980 | |
7981 Examples: > | |
7982 echo reduce([1, 3, 5], { acc, val -> acc + val }) | |
7983 echo reduce(['x', 'y'], { acc, val -> acc .. val }, 'a') | |
7984 echo reduce(0z1122, { acc, val -> 2 * acc + val }) | |
7985 < | |
7986 Can also be used as a |method|: > | |
7987 echo mylist->reduce({ acc, val -> acc + val }, 0) | |
7988 | |
7989 | |
7968 reg_executing() *reg_executing()* | 7990 reg_executing() *reg_executing()* |
7969 Returns the single letter name of the register being executed. | 7991 Returns the single letter name of the register being executed. |
7970 Returns an empty string when no register is being executed. | 7992 Returns an empty string when no register is being executed. |
7971 See |@|. | 7993 See |@|. |
7972 | 7994 |