Home Explore Blog CI



neovim

31th chunk of `runtime/doc/vimfn.txt`
f278a1b76cf8b0af7e9edda569a4de75e44228ceadf3784c0000000100000fb5
        Return: ~
                  (`string|string[]`)

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, use |flattennew()| if you do
		not want that.
								*E900*
		{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: >vim
			echo flatten([1, [2, [3, 4]], 5])
<			[1, 2, 3, 4, 5] >vim
			echo flatten([1, [2, [3, 4]], 5], 1)
<			[1, 2, [3, 4], 5]

                Parameters: ~
                  • {list} (`any[]`)
                  • {maxdepth} (`integer?`)

                Return: ~
                  (`any[]|0`)

flattennew({list} [, {maxdepth}])                                 *flattennew()*
		Like |flatten()| but first make a copy of {list}.

                Parameters: ~
                  • {list} (`any[]`)
                  • {maxdepth} (`integer?`)

                Return: ~
                  (`any[]|0`)

float2nr({expr})                                                    *float2nr()*
		Convert {expr} to a Number by omitting the part after the
		decimal point.
		{expr} must evaluate to a |Float| or a |Number|.
		Returns 0 if {expr} is not a |Float| or a |Number|.
		When the value of {expr} is out of range for a |Number| the
		result is truncated to 0x7fffffff or -0x7fffffff (or when
		64-bit Number support is enabled, 0x7fffffffffffffff or
		-0x7fffffffffffffff).  NaN results in -0x80000000 (or when
		64-bit Number support is enabled, -0x8000000000000000).
		Examples: >vim
			echo float2nr(3.95)
<			3  >vim
			echo float2nr(-23.45)
<			-23  >vim
			echo float2nr(1.0e100)
<			2147483647  (or 9223372036854775807) >vim
			echo float2nr(-1.0e150)
<			-2147483647 (or -9223372036854775807) >vim
			echo float2nr(1.0e-100)
<			0

                Parameters: ~
                  • {expr} (`number`)

                Return: ~
                  (`any`)

floor({expr})                                                          *floor()*
		Return the largest integral value less than or equal to
		{expr} as a |Float| (round down).
		{expr} must evaluate to a |Float| or a |Number|.
		Returns 0.0 if {expr} is not a |Float| or a |Number|.
		Examples: >vim
			echo floor(1.856)
<			1.0  >vim
			echo floor(-5.456)
<			-6.0  >vim
			echo floor(4.0)
<			4.0

                Parameters: ~
                  • {expr} (`number`)

                Return: ~
                  (`any`)

fmod({expr1}, {expr2})                                                  *fmod()*
		Return the remainder of {expr1} / {expr2}, even if the
		division is not representable.  Returns {expr1} - i * {expr2}
		for some integer i such that if {expr2} is non-zero, the
		result has the same sign as {expr1} and magnitude less than
		the magnitude of {expr2}.  If {expr2} is zero, the value
		returned is zero.  The value returned is a |Float|.
		{expr1} and {expr2} must evaluate to a |Float| or a |Number|.
		Returns 0.0 if {expr1} or {expr2} is not a |Float| or a
		|Number|.
		Examples: >vim
			echo fmod(12.33, 1.22)
<			0.13 >vim
			echo fmod(-12.33, 1.22)
<			-0.13

                Parameters: ~
                  • {expr1} (`number`)
                  • {expr2} (`number`)

                Return: ~
                  (`any`)

fnameescape({string})                                            *fnameescape()*
		Escape {string} for use as file name command argument.  All
		characters that have a special meaning, such as `'%'` and `'|'`
		are escaped with a backslash.
		For most systems the characters escaped are
		" \t\n*?[{`$\\%#'\"|!<".  For systems where a backslash
		appears in a filename, it depends on the value of 'isfname'.
		A leading '+' and '>' is also escaped (special after |:edit|
		and |:write|).  And a "-" by itself

Title: Vimscript Functions: `flattennew()`, `float2nr()`, `floor()`, `fmod()`, and `fnameescape()`
Summary
This section describes the `flattennew()` function, which is like `flatten()` but creates a copy of the input list first. It also covers `float2nr()`, which converts a float to a number by truncating the decimal part; `floor()`, which returns the largest integer less than or equal to a float; `fmod()`, which returns the floating-point remainder of a division; and `fnameescape()`, which escapes characters in a string for use as a filename command argument.