diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-02-01 20:14:51 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-02-01 20:14:51 +0100 |
commit | 3b690069730805a147d45d92eaca4dc838272d1d (patch) | |
tree | 47e970336167b1b23d8fac9e97b12cb76f159dd7 /runtime | |
parent | 9d20daffc296b9eb901fb14bdd83620ea55d440a (diff) | |
download | vim-git-3b690069730805a147d45d92eaca4dc838272d1d.tar.gz |
patch 8.2.2449: Vim9: flatten() always changes the list typev8.2.2449
Problem: Vim9: flatten() always changes the list type.
Solution: Disallow using flatten() and add flattennew().
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/eval.txt | 10 | ||||
-rw-r--r-- | runtime/doc/usr_41.txt | 1 |
2 files changed, 10 insertions, 1 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 1c4f46e6b..8bab49272 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2549,6 +2549,8 @@ finddir({name} [, {path} [, {count}]]) findfile({name} [, {path} [, {count}]]) String find file {name} in {path} flatten({list} [, {maxdepth}]) List flatten {list} up to {maxdepth} levels +flattennew({list} [, {maxdepth}]) + List flatten a copy of {list} float2nr({expr}) Number convert Float {expr} to a Number floor({expr}) Float round {expr} down fmod({expr1}, {expr2}) Float remainder of {expr1} / {expr2} @@ -4712,8 +4714,10 @@ flatten({list} [, {maxdepth}]) *flatten()* Flatten {list} up to {maxdepth} levels. Without {maxdepth} the result is a |List| without nesting, as if {maxdepth} is a very large number. - The {list} is changed in place, make a copy first if you do + The {list} is changed in place, use |flattennew()| if you do not want that. + In Vim9 script flatten() cannot be used, you must always use + |flattennew()|. *E900* {maxdepth} means how deep in nested lists changes are made. {list} is not modified when {maxdepth} is 0. @@ -4727,6 +4731,10 @@ flatten({list} [, {maxdepth}]) *flatten()* :echo flatten([1, [2, [3, 4]], 5], 1) < [1, 2, [3, 4], 5] +flattennew({list} [, {maxdepth}]) *flattennew()* + Like |flatten()| but first make a copy of {list}. + + float2nr({expr}) *float2nr()* Convert {expr} to a Number by omitting the part after the decimal point. diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index 965a97732..98e9a10a6 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -665,6 +665,7 @@ List manipulation: *list-functions* count() count number of times a value appears in a List repeat() repeat a List multiple times flatten() flatten a List + flattennew() flatten a copy of a List Dictionary manipulation: *dict-functions* get() get an entry without an error for a wrong key |