forked from aniani/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 #3676)
This commit is contained in:
@@ -2451,6 +2451,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}
|
||||
@@ -4514,6 +4515,25 @@ findfile({name} [, {path} [, {count}]]) *findfile()*
|
||||
Can also be used as a |method|: >
|
||||
GetName()->findfile()
|
||||
|
||||
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.
|
||||
|
||||
@@ -650,6 +650,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
|
||||
|
||||
Reference in New Issue
Block a user