diff options
author | Cédric Barreteau <> | 2020-06-30 18:39:54 +0200 |
---|---|---|
committer | Cédric Barreteau <> | 2020-07-15 20:27:20 +0200 |
commit | 6420615e3f703870ed898083f84d6e3515a8c279 (patch) | |
tree | 4ccc6606a2fc3b900f1c6a40e28a778e73762695 /runtime | |
parent | a02a267f8ad4b6d8b9038d2c7d9b85f03e734814 (diff) | |
download | rneovim-6420615e3f703870ed898083f84d6e3515a8c279.tar.gz rneovim-6420615e3f703870ed898083f84d6e3515a8c279.tar.bz2 rneovim-6420615e3f703870ed898083f84d6e3515a8c279.zip |
vim-patch:8.2.0935: flattening a list with existing code is slow
Problem: Flattening a list with existing code is slow.
Solution: Add flatten(). (Mopp, closes vim/vim#3676)
https://github.com/vim/vim/commit/077a1e670ad69ef4cefc22103ca6635bd269e764
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/eval.txt | 20 | ||||
-rw-r--r-- | runtime/doc/usr_41.txt | 1 |
2 files changed, 21 insertions, 0 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 1c1baa943a..a346262b0c 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2126,6 +2126,7 @@ finddir({name} [, {path} [, {count}]]) String find directory {name} in {path} findfile({name} [, {path} [, {count}]]) String find file {name} in {path} +flatten({list} [, {maxdepth}]) List flatten {list} up to {maxdepth} levels float2nr({expr}) Number convert Float {expr} to a Number floor({expr}) Float round {expr} down fmod({expr1}, {expr2}) Float remainder of {expr1} / {expr2} @@ -3918,6 +3919,25 @@ findfile({name} [, {path} [, {count}]]) *findfile()* < Searches from the directory of the current file upwards until it finds the file "tags.vim". +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 + not want that. + *E964* + {maxdepth} means how deep in nested lists changes are made. + {list} is not modified when {maxdepth} is 0. + {maxdepth} must be positive number. + + If there is an error the number zero is returned. + + Example: > + :echo flatten([1, [2, [3, 4]], 5]) +< [1, 2, 3, 4, 5] > + :echo flatten([1, [2, [3, 4]], 5], 1) +< [1, 2, [3, 4], 5] + 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 234f7801ab..31da51bfbe 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -644,6 +644,7 @@ List manipulation: *list-functions* min() minimum value in a List count() count number of times a value appears in a List repeat() repeat a List multiple times + flatten() flatten a List Dictionary manipulation: *dict-functions* get() get an entry without an error for a wrong key |