An operator is a special symbol that tells the interpreter to perform specific mathematical or logical operations. Lua provides the following types of operators:
Arithmetic operator
Relational operator
Logical operator
Other operators
4.18.1. Arithmetic operator #
The following table lists the common arithmetic operators in the Lua language, setting A to 10 and B to 20:
Operator | Description | Example |
|---|---|---|
| Addition | A + B output result 30 |
| Subtraction | A-B output result-10 |
| Multiplication | A * B output result 200 |
| Division | B / A output result 2 |
| Take the remainder | B An output result 0 |
| Multiplying power | A^2 output result 100 |
| Minus sign | -A output result-10 |
| Integer division operator (> = lua5.3) | 5Compact 2 output result 2 |
4.18.2. Example #
We can understand the application of arithmetic operators more thoroughly through the following examples: The execution results of the above procedures are as follows: In lua, / is used as a division operation, the result contains the decimal part, // is used as an integral division operation, and the result does notinclude the decimal part: The execution results of the above procedures are as follows:Example #
a = 21 b = 10 c = a + b print("The value of Line 1- c is ", c ) c = a - b print("The value of Line 2- c is ", c ) c = a * b print("The value of Line 3- c is ", c ) c = a / b print("The value of Line 4- c is ", c ) c = a % b print("The value of Line 5- c is ", c ) c = a^2 print("The value of Line 6- c is ", c ) c = -a print("The value of Line 7-c is ", c )
The value of Line 1- c is 31 The value of Line 2- c is 11 The value of Line 3- c is 210 The value of Line 4- c is 2.1 The value of Line 5- c is 1 The value of Line 6- c is 441 The value of Line 7- c is -21
Example #
a = 5 b = 2 print("The value of division operation - a/b is ", a / b ) print("The value of integer division - a/b is ", a // b )
Division operation - the value of a/b is 2.5 The value of integer division - a/b is 2
4.18.3. Relational operator #
The following table lists the common relational operators in the Lua language, setting the value of A to 10 and the value of B to 20:
Operator | Description | Example |
|---|---|---|
== | Equals, checks whether two values are equal, returns true, otherwise returnsfalse | (A == B) is false. |
~= | Not equal. Check whether two values are equal. Return true if they are not equal, otherwise return false. | (A ~= B) is true. |
> | Greater than, if the value on the left is greater than the value on the right, return true, otherwise return false | (A > B) is false. |
< | Less than, if the value on the left is greater than the value on the right, return false, otherwise return true | (A < B) is true. |
>= | Greater than or equal to, if the value on the left is greater than or equal to the value on the right, return true, otherwise return false | (A >= B) returns false. |
<= | Less than or equal to, if the value on the left is less than or equal to thevalue on the right, return true, otherwise return false | (A <= B) returns true. |
4.18.4. Example #
We can understand the application of relational operators more thoroughly through the following examples: The execution results of the above procedures are as follows:Example #
a = 21 b = 10 if( a == b ) then print("Line 1 - a = b" ) else print("Line 1 - a ≠ b" ) end if( a ~= b ) then print("Line 2 - a ≠ b" ) else print("Line 2 - a = b" ) end if ( a < b ) then print("Line 3 - a < b" ) else print("Line 3 - a ≥ b" ) end if ( a > b ) then print("Line 4 - a > b" ) else print("Line 5 - a ≤ b" ) end -- Modify the values of a and b a = 5 b = 20 if ( a <= b ) then print("Line 5 - a ≤ b" ) end if ( b >= a ) then print("Line 6 - b ≥ a" ) end
Line 1 - a ≠ b Line 2 - a ≠ b Line 3 - a ≥ b Line 4 - a > b Line 5 - a ≤ b Line 6 - b ≥ a
4.18.5. Logical operator #
The following table lists the common logical operators in the Lua language, setting the value of A to true , the value of B is false :
Operator | Description | Example |
|---|---|---|
and | Logic and operators. If A is false, return A, otherwise return B. | (A and B) is false. |
or | Logic or operator. If A is true, return A, otherwise return B. | (A or B) is true. |
not | Logical non-operator. Contrary to the logic operation result, if the condition is true, the logic is not false. | not (A and B) is true. |
4.18.6. Example #
We can understand the application of logical operators more thoroughly through the following examples: The execution results of the above procedures are as follows:Example #
a = true b = true if ( a and b ) then print("a and b - Condition is true" ) end if ( a or b ) then print("a or b - Condition is true" ) end print("---------Divider---------" ) -- Modify the values of a and b a = false b = true if ( a and b ) then print("a and b - Condition is true" ) else print("a and b - Condition is false" ) end if ( not( a and b) ) then print("not( a and b) - Condition is true" ) else print("not( a and b) - Condition is false" ) end
a and b - Condition is true a or b - Condition is true ---------Divider--------- a and b - Condition is false not( a and b) - Condition is true
4.18.7. Other operators #
The following table lists the concatenation operators in the Lua language and operators that calculate the length of a table or string:
Operator | Description | Example |
|---|---|---|
Concatenate two strings | a..b, where an is “Hello”, b is “World”, and the output is “Hello World”. | |
# | Unary operator that returns the length of a string or table. | #”Hello” returns 5 |
4.18.8. Example #
We can better understand the application of concatenation operators and operators that calculate the length of tables or strings through the following examples: The execution results of the above procedures are as follows:Example #
a = "Hello " b = "World" print("Connection strings a and b ", a..b ) print("B String length ",#b ) print("String Test Length ",#"Test" ) print("Newbie tutorial website length ",#"www.runoob.com" )
Connection strings a and b Hello World B String length 5 String Test Length 4 Newbie tutorial website length 14
4.18.9. Operator precedence #
The order from high to low:
^ not - (unary) * / % + - .. < > <= >= ~= == and or Except ^ and .. all binary operators outside are left concatenated.
a+i < b/2+1 <--> (a+i) < ((b/2)+1) 5+x^2*8 <--> 5+((x^2)*8) a < y and y <= z <--> (a < y) and (y <= z) -x^2 <--> -(x^2) x^y^z <--> x^(y^z) 4.18.10. Example #
We can get a more thorough understanding of the precedence of Lua language operators through the following examples:
Example #
a = 20 b = 10 c = 15 d = 5 e = (a + b) * c / d;-- ( 30 * 15 ) / 5 print("(a + b) * c / d operation value is :",e ) e = ((a + b) * c) / d; -- (30 * 15 ) / 5 print("((a + b) * c) / d operation value is :",e ) e = (a + b) * (c / d);-- (30) * (15/5) print("(a + b) * (c / d) operation value is :",e ) e = a + (b * c) / d; -- 20 + (150/5) print("a + (b * c) / d operation value is :",e )
The execution results of the above procedures are as follows:
(a + b) * c / d operation value is : 90.0 ((a + b) * c) / d operation value is : 90.0 (a + b) * (c / d) operation value is : 90.0 a + (b * c) / d operation value is : 50.0
-
1. Angularjs2
8
-
1. SVG tutorial
19
-
1. Memcached
20
-
1. C# tutorial
61
-
1. Sqlite
47
-
2. Go
43
-
2. Docker
59
-
2. Vue3
19
-
2. Servlet
21
-
3. React
23
-
3. SOAP tutorial
10
-
3. Android
18
-
3. Mongodb
44
-
3. Kotlin
18
-
4. Lua
31
-
4.15. Lua if…else statement
-
4.1. Lua tutorial
-
4.28. Lua debugging
-
4.27. Lua error handling
-
4.25. Lua collaborative program (coroutine)
-
>
4.18. Lua operator
-
4.26. Lua file I/O
-
4.23. Lua modules and packages
-
4.3. Lua basic syntax
-
4.31. Lua database access
-
4. MySQL tutorial
35
-
4. Appml
12
-
5. Perl
45
-
5. Postgresql
41
-
web
15
-
5. Web Services tutorial
6
-
6. Ruby
42
-
6. Design-pattern
35
-
7. Django
18
-
7. Rust
22
-
6. WSDL tutorial
8
-
8. Foundation
39
-
9. Ios
43
-
8. Css3
26
-
9. Swift
44
-
11. HTML tutorial-(HTML5 Standard)
54
-
12. Http
6
-
13. Regex
6
-
14. Regexp
8
《地理信息系统原理、技术与方法》
97
最近几年来,地理信息系统无论是在理论上还是应用上都处在一个飞速发展的阶段。 GIS被应用于多个领域的建模和决策支持,如城市管理、区划、环境整治等等,地理信息成为信息时代重要的组成部分之一; “数字地球”概念的提出,更进一步推动了作为其技术支撑的GIS的发展。 与此同时,一些学者致力于相关的理论研究,如空间感知、空间数据误差、空间关系的形式化等等。 这恰好说明了地理信息系统作为应用技术和学科的两个方面,并且这两个方面构成了相互促进的发展过程。
-
1. Introduction to geographic information system
6
-
2. From the Real World to the Bit World
3
-
3. Spatial Data Model
7
-
4. 空间参照系统和 地图投影
5
-
5. Data in GIS
3
-
6. Spatial data acquisition
2
-
7. Spatial Data Management
6
-
8. Spatial analysis
8
-
9. 数字地形模型( DTM )与地形分析
5
-
10. 空间建模与 空间决策支持
6
-
11. Spatial data representation and map making
6
-
12. 3S Integration Technology
5
-
13. 网络地理信息系统
3
-
14. Examples of Geographic Information System Application
8
-
15. Organization and Management of Geographic Information System Application Projects
9
-
16. Geographic Information system Software Engineering Technology
6
-
17. Geographic Information System Standards
3
-
18. Geographic Information System and Society
3
-
19. Earth Information Science and Digital Earth
3