Lua standard library (RPM)

Source: Internet
Author: User
Tags mathematical functions

Reprint Address: http://www.yiibai.com/lua/lua_standard_libraries.html

LUA's standard library provides a rich set of features that are implemented directly with the C API, built on LUA programming language functions. These libraries provide services in the LUA programming language and also provide external services, such as file and database operations.

Built on the official C API, these standard libraries are as separate C modules. This includes:

    • Basic libraries, including co-location

    • Module Library

    • String manipulation

    • Table Operations

    • Math Library

    • File input and output

    • Operating System Tools

    • Commissioning Equipment

Basic Library

The basic library we use is based on tutorials across different topics. The following table provides links to all relevant Web pages and lists the functions that will be included in the various components of LUA in this tutorial

S.N. Libraries/methods and uses
1. Error Handling
Includes error handling features such as assertions, errors-error handling.
2. Memory Management
I includes automatic memory management functions explained in the garbage collection Lua
3. Dofile ([filename])
It opens the file and executes the contents of the file as a block. If passed without parameters, the function executes the contents of the standard input. These errors are propagated to the caller.
4. _g
Thus is to maintain global environment global variables (i.e., _g._g=_g). LUA itself does not use this variable.
5. Getfenv ([f])
Returns the functionality used in the current environment. F can be a LUA function or number that specifies a function at the protocol stack level: Level 1 is a function call getfenv. If the given function is not a LUA function, or if f is 0,getfenv returns to the global environment. The default is F is 1.
6. Getmetatable (object)
Returns nil if the object has no meta-table. Otherwise, if the object's meta-table has a "__metatable" field, the relevant value is returned. Otherwise, returns the meta-table for the given object.
7. Ipairs (t)
This function reads the index and value of the table.
8. Load (func [, Chunkname])
Use the Load function func to get its partial block. Each call to Func must return a connection string with the previous result.
9. LoadFile ([filename]))
Similar to loading, but the block from the file name or from the standard input, if no file name is given.
10. LoadString (string [, Chunkname])
A block of blocks similar to loading, but getting from a given string.
11. Next (table [, index])
Allows the program to traverse all fields of the table. Its first argument is a table, and its second parameter is the index of the table. Next, an index of the table and its associated values is returned.
12. Pairs (t)
Pauses the running of the process. The parameter passed to the method is used as an additional return value to restore functionality.
13. Print (...)
Pauses the running of the process. The parameter passed to the method is used as an additional return value to restore functionality.
14. Rawequal (v1, v2)
Checks if V1 is equal to V2, and does not call any meta methods. Returns a Boolean value.
15. Rawget (table, index)
Gets the true value of the table [index] without calling any meta methods. The table must be a table, and the index can be any value.
16. Rawset (table, index, value)
Set the table [index] value, the true value does not call any meta methods. The table must be a table, indexed from a different value without any value, Lua. This function returns the table.
17. Select (Index, ...)
If the index is a number, returns all parameters of the index after the number of arguments. Otherwise, the index must be the string "#" and then choose to return to the total number of additional parameters.
18. Setfenv (f, table)
Sets the environment for the specific function to be used. F is a LUA function or number that specifies a function at the protocol stack level: Level 1 is a function call setfenv. SETFENV returns the given function. As a special case, when F is 0 setfenv changes the environment of the running thread. In this case, SETFENV does not return any values.
19. Setmetatable (table, metatable)
Sets the meta table to the given table. (It is not possible to change other types of meta tables from LUA, only from c) if the meta table is zero, eliminating the meta table for a given table. If the original metatable has a "__metatable" field, an error is raised. This function returns the table.
20. Tonumber (e [, Base])
Attempts to convert its arguments to numbers. If the argument is already a number or a string is converted to a number, then Tonumber returns the number; otherwise, nil is returned.
21st. ToString (E)
Receive any type of argument and convert it to a string, in a reasonable format. For full control on how to convert the number, use String.Format.
22. Type (v)
Returns the type of its unique argument, encoded as a string. The possible result of this function is "nil" (string, instead of a value of 0), "number", "string", "Boolean", "table", "function", "line" and "User Data".
23. Unpack (list [, I [, J]])
Returns the elements from the given table.
24. _version
A global variable (not a function) holds a string containing the current translated version. The current content of this variable is "Lua5.1".
25. Coroutines
Includes co-operation function
Module Library

These module libraries provide the basic functional module loading in LUA. It exports a function directly in the Global environment: require. Export all the packages in the table. The details of the module library are explained in the previous chapters

String manipulation

A rich set of string-handling functions is available in Lua. The Lua-string tutorial introduces this detail.

Table Operations

LUA relies on almost every bit of operations in a table. The earlier lua-table tutorial introduces this detail.

Math Library

In any programming language, mathematical functions usually require a variety of scientific and engineering calculations.

File input and output

We often need to program the data storage device, which is a standard library function for file I/O in Lua. The early Lua file I/O tutorials are discussed.

Operating System Tools

Sometimes, we may need access to the operating system features. These functions are explained in LUA-operating system tools tutorials.

Commissioning Equipment

LUA provides a debug library that provides all the basic functions that we use to create our own debuggers.

Lua standard library (RPM)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.