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. Geographical Information Systems in the World Wide Web Era
4
-
2. Basic technology of WebGIS
4
-
3. Geographic Web Services
5
-
4. aggregation of geographical information
4
-
5. mobile GIS
5
-
6. Geographic information portal
3
-
7. New generation national spatial data infrastructure and GIS
4
-
8. Application of WebGIS in E-Commerce
3
-
9. Application of WebGIS in E-government
3
-
10. Hotspots and frontiers of WebGIS
2
-
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. MySQL tutorial
34
-
4. Appml
12
-
5. Perl
45
-
5. Postgresql
41
-
web
15
-
5. Web Services tutorial
6
-
6. Ruby
41
-
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
43
-
11. HTML tutorial-(HTML5 Standard)
54
-
12. Http
6
-
13. Regex
6
-
14. Regexp
7
Principles, Technologies, and Methods of Geographic Information Systems
102
In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.
-
1. Introduction to Geographic Information Systems
6
-
2. From the Real World to the Bit World
3
-
3. Spatial Data Model
7
-
4. Spatial Reference Systems and Map Projections
5
-
5. Data in GIS
4
-
6. Spatial data acquisition
2
-
7. Spatial Data Management
6
-
8. Spatial analysis
8
-
9. Digital Terrain Model (DTM) and Terrain Analysis
5
-
10. Spatial modeling and spatial decision support
6
-
11. Spatial data representation and map making
6
-
12. 3S Integration Technology
5
-
13. Network Geographic Information System
4
-
14. Examples of Geographic Information System Application
8
-
15. Organization and Management of Geographic Information System Application Projects
10
-
16. Geographic Information system Software Engineering Technology
7
-
17. Geographic Information System Standards
3
-
18. Geographic Information System and Society
3
-
19. Earth Information Science and Digital Earth
4