Home Explore Blog CI



neovim

66th chunk of `runtime/doc/luaref.txt`
40523dc62b5b82b8e0a493ea549151f903dce4986f983bf50000000100000fa0
 value of `table.foreach`.

        See |next()| for extra information about table traversals.

table.foreachi({table}, {f})                                  *table.foreachi()*
        Executes the given {f} over the numerical indices of {table}. For each
        index, {f} is called with the index and respective value as arguments.
        Indices are visited in sequential order, from 1 to `n`, where `n` is
        the length of the table. If {f} returns a non-`nil` value, then the
        loop is broken and this value is returned as the result of
        `table.foreachi`.

table.insert({table}, [{pos},] {value})                         *table.insert()*
        Inserts element {value} at position {pos} in {table}, shifting up
        other elements to open space, if necessary. The default value for
        {pos} is `n+1`, where `n` is the length of the table (see
        |lua-length|), so that a call `table.insert(t,x)` inserts `x`
        at the end of table `t`.

table.maxn({table})                                               *table.maxn()*
        Returns the largest positive numerical index of the given table, or
        zero if the table has no positive numerical indices. (To do its job
        this function does a linear traversal of the whole table.)

table.remove({table} [, {pos}])                                 *table.remove()*
        Removes from {table} the element at position {pos}, shifting down
        other elements to close the space, if necessary. Returns the value of
        the removed element. The default value for {pos} is `n`, where `n` is
        the length of the table (see |lua-length|), so that a call
        `table.remove(t)` removes the last element of table `t`.

table.sort({table} [, {comp}])                                    *table.sort()*
        Sorts table elements in a given order, `in-place`, from `table[1]` to
        `table[n]`, where `n` is the length of the table (see |lua-length|).
        If {comp} is given, then it must be a function that receives two table
        elements, and returns true when the first is less than the second (so
        that `not comp(a[i+1],a[i])` will be true after the sort). If {comp}
        is not given, then the standard Lua operator `<` is used instead.

The sort algorithm is `not` stable, that is, elements considered equal by the
given order may have their relative positions changed by the sort.

==============================================================================
5.6  Mathematical Functions                                     *lua-lib-math*

This library is an interface to most of the functions of the standard C math
library. It provides all its functions inside the table `math`.

math.abs({x})                                                       *math.abs()*
        Returns the absolute value of {x}.

math.acos({x})                                                     *math.acos()*
        Returns the arc cosine of {x} (in radians).

math.asin({x})                                                     *math.asin()*
        Returns the arc sine of {x} (in radians).

math.atan({x})                                                     *math.atan()*
        Returns the arc tangent of {x} (in radians).

math.atan2({x}, {y})                                              *math.atan2()*
        Returns the arc tangent of `x/y` (in radians), but uses the signs of
        both parameters to find the quadrant of the result. (It also handles
        correctly the case of {y} being zero.)

math.ceil({x})                                                     *math.ceil()*
        Returns the smallest integer larger than or equal to {x}.

math.cos({x})                                                       *math.cos()*
        Returns the cosine of {x} (assumed to be in radians).

math.cosh({x})                                                     *math.cosh()*
        Returns the hyperbolic cosine of {x}.

math.deg({x})                                        

Title: Lua Table and Math Libraries: Functions and Usage
Summary
This section details functions from the Lua `table` library such as `table.maxn`, `table.remove`, and `table.sort` for array manipulation. It also covers the `math` library, providing functions like `math.abs`, `math.acos`, `math.asin`, `math.atan`, `math.atan2`, `math.ceil`, `math.cos`, and `math.cosh`, mirroring the standard C math library's functionality.