当前位置: 首页 > article >正文

跟着 Lua 5.1 官方参考文档学习 Lua (3)

文章目录

    • 2.5 – Expressions
      • 2.5.1 – Arithmetic Operators
      • 2.5.2 – Relational Operators
      • 2.5.3 – Logical Operators
      • 2.5.4 – Concatenation
      • 2.5.5 – The Length Operator
      • 2.5.6 – Precedence
      • 2.5.7 – Table Constructors
      • 2.5.8 – Function Calls
      • 2.5.9 – Function Definitions
    • 2.6 – Visibility Rules

2.5 – Expressions

The basic expressions in Lua are the following:

	exp ::= prefixexpexp ::= nil | false | trueexp ::= Numberexp ::= Stringexp ::= functionexp ::= tableconstructorexp ::= `...´exp ::= exp binop expexp ::= unop expprefixexp ::= var | functioncall | `(´ exp `)´

Numbers and literal strings are explained in §2.1;

variables are explained in §2.3;

function definitions are explained in §2.5.9;

function calls are explained in §2.5.8;

table constructors are explained in §2.5.7.

Vararg expressions, denoted by three dots (‘...’), can only be used when directly inside a vararg function; they are explained in §2.5.9.

Binary operators comprise arithmetic operators (see §2.5.1), relational operators (see §2.5.2), logical operators (see §2.5.3), and the concatenation operator (see §2.5.4).

Unary operators comprise the unary minus (see §2.5.1), the unary not (see §2.5.3), and the unary length operator (see §2.5.5).

Both function calls and vararg expressions can result in multiple values. If an expression is used as a statement (only possible for function calls (see §2.4.6)), then its return list is adjusted to zero elements, thus discarding all returned values. If an expression is used as the last (or the only) element of a list of expressions, then no adjustment is made (unless the call is enclosed in parentheses). In all other contexts, Lua adjusts the result list to one element, discarding all values except the first one.

Here are some examples:

     f()                -- adjusted to 0 resultsg(f(), x)          -- f() is adjusted to 1 resultg(x, f())          -- g gets x plus all results from f()a,b,c = f(), x     -- f() is adjusted to 1 result (c gets nil)a,b = ...          -- a gets the first vararg parameter, b gets-- the second (both a and b can get nil if there-- is no corresponding vararg parameter)a,b,c = x, f()     -- f() is adjusted to 2 resultsa,b,c = f()        -- f() is adjusted to 3 resultsreturn f()         -- returns all results from f()return ...         -- returns all received vararg parametersreturn x,y,f()     -- returns x, y, and all results from f(){f()}              -- creates a list with all results from f(){...}              -- creates a list with all vararg parameters{f(), nil}         -- f() is adjusted to 1 result

Any expression enclosed in parentheses always results in only one value. Thus, (f(x,y,z)) is always a single value, even if f returns several values. (The value of (f(x,y,z)) is the first value returned by f or nil if f does not return any values.)

2.5.1 – Arithmetic Operators

Lua supports the usual arithmetic operators: the binary + (addition), - (subtraction), * (multiplication), / (division), % (modulo), and ^ (exponentiation); and unary - (negation). If the operands are numbers, or strings that can be converted to numbers (see §2.2.1), then all operations have the usual meaning. Exponentiation works for any exponent. For instance, x^(-0.5) computes the inverse of the square root of x. Modulo is defined as

     a % b == a - math.floor(a/b)*b

That is, it is the remainder of a division that rounds the quotient towards minus infinity.

2.5.2 – Relational Operators

The relational operators in Lua are

     ==    ~=    <     >     <=    >=

These operators always result in false or true.

Equality (==) first compares the type of its operands. If the types are different, then the result is false. Otherwise, the values of the operands are compared.

Numbers and strings are compared in the usual way.

Objects (tables, userdata, threads, and functions) are compared by reference: two objects are considered equal only if they are the same object. Every time you create a new object (a table, userdata, thread, or function), this new object is different from any previously existing object.

You can change the way that Lua compares tables and userdata by using the “eq” metamethod (see §2.8).

The conversion rules of §2.2.1 do not apply to equality comparisons. Thus, "0"==0 evaluates to false, and t[0] and t["0"] denote different entries in a table.

The operator ~= is exactly the negation of equality (==).

The order operators work as follows. If both arguments are numbers, then they are compared as such. Otherwise, if both arguments are strings, then their values are compared according to the current locale. Otherwise, Lua tries to call the “lt” or the “le” metamethod (see §2.8). A comparison a > b is translated to b < a and a >= b is translated to b <= a.

2.5.3 – Logical Operators

The logical operators in Lua are and, or, and not. Like the control structures (see §2.4.4), all logical operators consider both false and nil as false and anything else as true.

The negation operator not always returns false or true.

The conjunction operator and returns its first argument if this value is false or nil; otherwise, and returns its second argument. 【0&0=0, 0&1=0】

The disjunction operator or returns its first argument if this value is different from nil and false; otherwise, or returns its second argument. 【1|0=1, 1|1=1, 0|0=0, 0|1=1】

Both and and or use short-cut evaluation; that is, the second operand is evaluated only if necessary. Here are some examples:

     10 or 20            --> 1010 or error()       --> 10nil or "a"          --> "a"nil and 10          --> nilfalse and error()   --> falsefalse and nil       --> falsefalse or nil        --> nil10 and 20           --> 20

(In this manual, --> indicates the result of the preceding expression.)

2.5.4 – Concatenation

The string concatenation operator in Lua is denoted by two dots (‘..’). If both operands are strings or numbers, then they are converted to strings according to the rules mentioned in §2.2.1. Otherwise, the “concat” metamethod is called (see §2.8).

2.5.5 – The Length Operator

The length operator is denoted by the unary operator #. The length of a string is its number of bytes (that is, the usual meaning of string length when each character is one byte).

The length of a table t is defined to be any integer index n such that t[n] is not nil and t[n+1] is nil; moreover, if t[1] is nil, n can be zero.

For a regular array, with non-nil values from 1 to a given n, its length is exactly that n, the index of its last value. If the array has “holes” (that is, nil values between other non-nil values), then #t can be any of the indices that directly precedes a nil value (that is, it may consider any such nil value as the end of the array).

补充:If you really need to handle arrays with holes up to their last index, you can use the function table.maxn, which returns the largest numerical positive index of a table.

The length operator provides several common Lua idioms:

print(a[#a]) -- prints the last value of list ’a’
a[#a] = nil -- removes this last value
a[#a+1] = v -- appends ’v’ to the end of the list  

例子:从标准输入读取10行数据

a = {}
for i=1,10 doa[#a+1] = io.read()
end

例子:

t = {}
t[10000] = 1
print(#t) -- 长度为0,因为t[1]为nilt = {}
t[1] = 1
t[2] = 1
t[3] = 1t[10000] = 1
print(#t) -- 长度为3print(table.maxn(t)) -- 输出 10000

2.5.6 – Precedence

Operator precedence in Lua follows the table below, from lower to higher priority:

     orand<     >     <=    >=    ~=    ==..+     -*     /     %not   #     - (unary)^

As usual, you can use parentheses to change the precedences of an expression. The concatenation (‘..’) and exponentiation (‘^’) operators are right associative. All other binary operators are left associative.

例子:^ 和 … 的右结合性

print(2^2^3) -- 2^(2^3) 而不是(2^2)^3print("a" .. "b" .. "c") -- "a" .. ("b" .. "c") 而不是 ("a" .. "b") .. "c"

补充:

Therefore, the following expressions on the left are equivalent to those on the right:

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)

When in doubt, always use explicit parentheses.

2.5.7 – Table Constructors

Table constructors are expressions that create tables. Every time a constructor is evaluated, a new table is created. A constructor can be used to create an empty table or to create a table and initialize some of its fields. The general syntax for constructors is

	tableconstructor ::= `{´ [fieldlist] `}´fieldlist ::= field {fieldsep field} [fieldsep]field ::= `[´ exp `]´ `=´ exp | Name `=´ exp | expfieldsep ::= `,´ | `;´

Each field of the form [exp1] = exp2 adds to the new table an entry with key exp1 and value exp2. A field of the form name = exp is equivalent to ["name"] = exp. Finally, fields of the form exp are equivalent to [i] = exp, where i are consecutive numerical integers, starting with 1. Fields in the other formats do not affect this counting.

For example,

     a = { [f(1)] = g; "x", "y"; x = 1, f(x), [30] = 23; 45 }

is equivalent to

     dolocal t = {}t[f(1)] = gt[1] = "x"         -- 1st expt[2] = "y"         -- 2nd expt.x = 1            -- t["x"] = 1t[3] = f(x)        -- 3rd expt[30] = 23t[4] = 45          -- 4th expa = tend

If the last field in the list has the form exp and the expression is a function call or a vararg expression, then all values returned by this expression enter the list consecutively (see §2.5.8). To avoid this, enclose the function call or the vararg expression in parentheses (see §2.5).

The field list can have an optional trailing separator, as a convenience for machine-generated code.

2.5.8 – Function Calls

A function call in Lua has the following syntax:

	functioncall ::= prefixexp argsprefixexp ::= var | functioncall | `(´ exp `)´

In a function call, first prefixexp and args are evaluated. If the value of prefixexp has type function, then this function is called with the given arguments. Otherwise, the prefixexp “call” metamethod is called, having as first parameter the value of prefixexp, followed by the original call arguments (see §2.8).

The form

	functioncall ::= prefixexp `:´ Name args

can be used to call “methods”. A call v:name(args) is syntactic sugar for v.name(v,args), except that v is evaluated only once.

Arguments have the following syntax:

	args ::= `(´ [explist] `)´args ::= tableconstructorargs ::= String

All argument expressions are evaluated before the call.

A call of the form f{fields} is syntactic sugar for f({fields}); that is, the argument list is a single new table.

A call of the form f'string' (or f"string" or f[[string]]) is syntactic sugar for f('string'); that is, the argument list is a single literal string.

例子:函数参数语法的三种形式

function foo(a)print(a)
endfoo(1)   -- 1foo"abc" -- abcfoo{1,2,3} -- table: ...

As an exception to the free-format syntax of Lua, you cannot put a line break before the ‘(’ in a function call. This restriction avoids some ambiguities in the language. If you write

     a = f(g).x(a)

Lua would see that as a single statement, a = f(g).x(a). So, if you want two statements, you must add a semi-colon between them. If you actually want to call f, you must remove the line break before (g).

A call of the form return functioncall is called a tail call. Lua implements proper tail calls (or proper tail recursion): in a tail call, the called function reuses the stack entry of the calling function. Therefore, there is no limit on the number of nested tail calls that a program can execute. However, a tail call erases any debug information about the calling function.

Note that a tail call only happens with a particular syntax, where the return has one single function call as argument; this syntax makes the calling function return exactly the returns of the called function. So, none of the following examples are tail calls:

     return (f(x))        -- results adjusted to 1return 2 * f(x)return x, f(x)       -- additional resultsf(x); return         -- results discardedreturn x or f(x)     -- results adjusted to 1

2.5.9 – Function Definitions

The syntax for function definition is

	function ::= function funcbodyfuncbody ::= `(´ [parlist] `)´ block end

The following syntactic sugar simplifies function definitions:

	stat ::= function funcname funcbodystat ::= local function Name funcbodyfuncname ::= Name {`.´ Name} [`:´ Name]

The statement

     function f () body end

translates to

     f = function () body end

The statement

     function t.a.b.c.f () body end

translates to

     t.a.b.c.f = function () body end

The statement

     local function f () body end

translates to

     local f; f = function () body end

not to

     local f = function () body end

(This only makes a difference when the body of the function contains references to f.)

补充:So, we can use this syntax for recursive functions without worrying:

local function fact (n)if n == 0 then return 1else return n*fact(n-1)end
end  

A function definition is an executable expression, whose value has type function.

When Lua pre-compiles a chunk, all its function bodies are pre-compiled too. Then, whenever Lua executes the function definition, the function is instantiated (or closed). This function instance (or closure) is the final value of the expression. Different instances of the same function can refer to different external local variables and can have different environment tables.


补充:When a function is written enclosed in another function, it has full access to local variables from the enclosing function; this feature is called lexical scoping.

例子:闭包

names = {"Peter", "Paul", "Mary"}
grades = {Mary = 10, Paul = 7, Peter = 8}function sortbygrade (names, grades)table.sort(names, function (n1, n2)return grades[n1] > grades[n2] -- compare the gradesend)
endsortbygrade(names, grades)for _, v in ipairs(names) doprint(v)
end

The interesting point in the example is that the anonymous function given to sort accesses the parameter grades, which is local to the enclosing function sortbygrade. Inside this anonymous function, grades is neither a global variable nor a local variable, but what we call a non-local variable. (For historical reasons, non-local variables are also called upvalues in Lua.)

例子:使用闭包实现计数器

function newCounter ()local i = 0return function () -- anonymous functioni = i + 1return iend
endc1 = newCounter()
print(c1()) --> 1
print(c1()) --> 2c2 = newCounter()
print(c2()) --> 1
print(c1()) --> 3
print(c2()) --> 2

In this code, the anonymous function refers to a non-local variable, i, to keep its counter. However, by the time we call the anonymous function, i is already out of scope, because the function that created this variable (newCounter) has returned. Nevertheless, Lua handles this situation correctly, using the concept of closure. Simply put, a closure is a function plus all it needs to access nonlocal variables correctly.

Technically speaking, what is a value in Lua is the closure, not the function. The function itself is just a prototype for closures. Nevertheless, we will continue to use the term “function” to refer to a closure whenever there is no possibility of confusion.


Parameters act as local variables that are initialized with the argument values:

	parlist ::= namelist [`,´ `...´] | `...´

When a function is called, the list of arguments is adjusted to the length of the list of parameters, unless the function is a variadic or vararg function, which is indicated by three dots (‘...’) at the end of its parameter list.

A vararg function does not adjust its argument list; instead, it collects all extra arguments and supplies them to the function through a vararg expression, which is also written as three dots. The value of this expression is a list of all actual extra arguments, similar to a function with multiple results.

If a vararg expression is used inside another expression or in the middle of a list of expressions, then its return list is adjusted to one element. If the expression is used as the last element of a list of expressions, then no adjustment is made (unless that last expression is enclosed in parentheses).

As an example, consider the following definitions:

     function f(a, b) endfunction g(a, b, ...) endfunction r() return 1,2,3 end

Then, we have the following mapping from arguments to parameters and to the vararg expression:

     CALL            PARAMETERSf(3)             a=3, b=nilf(3, 4)          a=3, b=4f(3, 4, 5)       a=3, b=4f(r(), 10)       a=1, b=10f(r())           a=1, b=2g(3)             a=3, b=nil, ... -->  (nothing)g(3, 4)          a=3, b=4,   ... -->  (nothing)g(3, 4, 5, 8)    a=3, b=4,   ... -->  5  8g(5, r())        a=5, b=1,   ... -->  2  3

Results are returned using the return statement (see §2.4.4). If control reaches the end of a function without encountering a return statement, then the function returns with no results.

The colon syntax is used for defining methods, that is, functions that have an implicit extra parameter self. Thus, the statement

     function t.a.b.c:f (params) body end

is syntactic sugar for

     t.a.b.c.f = function (self, params) body end

2.6 – Visibility Rules

Lua is a lexically scoped language. The scope of variables begins at the first statement after their declaration and lasts until the end of the innermost block that includes the declaration. Consider the following example:

     x = 10                -- global variabledo                    -- new blocklocal x = x         -- new 'x', with value 10print(x)            --> 10x = x+1do                  -- another blocklocal x = x+1     -- another 'x'print(x)          --> 12endprint(x)            --> 11endprint(x)              --> 10  (the global one)

Notice that, in a declaration like local x = x, the new x being declared is not in scope yet, and so the second x refers to the outside variable.

Because of the lexical scoping rules, local variables can be freely accessed by functions defined inside their scope. A local variable used by an inner function is called an upvalue, or external local variable, inside the inner function.

Notice that each execution of a local statement defines new local variables. Consider the following example:

     a = {}local x = 20for i=1,10 dolocal y = 0a[i] = function () y=y+1; return x+y endend

The loop creates ten closures (that is, ten instances of the anonymous function). Each of these closures uses a different y variable, while all of them share the same x.

相关文章:

跟着 Lua 5.1 官方参考文档学习 Lua (3)

文章目录 2.5 – Expressions2.5.1 – Arithmetic Operators2.5.2 – Relational Operators2.5.3 – Logical Operators2.5.4 – Concatenation2.5.5 – The Length Operator2.5.6 – Precedence2.5.7 – Table Constructors2.5.8 – Function Calls2.5.9 – Function Definiti…...

PyTorch 源码学习:阅读经验 代码结构

分享自己在学习 PyTorch 源码时阅读过的资料。本文重点关注阅读 PyTorch 源码的经验和 PyTorch 的代码结构。因为 PyTorch 不同版本的源码实现有所不同&#xff0c;所以笔者在整理资料时尽可能按版本号升序&#xff0c;版本号见标题前[]。最新版本的源码实现还请查看 PyTorch 仓…...

力扣-二叉树-501 二叉搜索树的众数

思路 二叉搜索树的特性就是中序遍历有序&#xff0c;所以思考时可以先按照有序数组思考 代码 class Solution { public:vector<int> result;TreeNode* pre nullptr;int count 1;int maxCount 0;void travesl(TreeNode* node){if(node nullptr) return;travesl(nod…...

vscode复制到下一行

linux中默认快捷键是ctrl shift alt down/up 但是在vscode中无法使用&#xff0c;应该是被其他的东西绑定了&#xff0c;经测试&#xff0c;可以使用windows下的快捷键shift alt down/up { “key”: “shiftaltdown”, “command”: “editor.action.copyLinesDownAction”…...

vscode将文件中行尾默认CRLF改为LF

安装prettier npm install --save-dev --save-exact prettier执行命令 npx prettier --write --end-of-line lf .即可将项目中的所有文件行尾序列格式改为lf *在你使用git拉取代码的时候&#xff0c;git会自动将代码当中与你当前系统不同的换行方式转化成你当前系统的换行方…...

Windows 环境下配置多个不同版本的 Maven

在实际开发中,不同的项目可能需要使用不同版本的 Maven。例如,老项目可能依赖于 Maven 3.3,而新项目可能需要 Maven 3.8+ 才能正常运行。因此,在 Windows 下配置多个 Maven 版本并能方便地切换是非常必要的 1. 下载并安装多个 Maven 版本 1.1 下载 Maven 访问 Apache Mav…...

网络运维学习笔记 013网工初级(HCIA-Datacom与CCNA-EI)DHCP动态主机配置协议(此处没讲思科)

文章目录 DHCP&#xff08;Dynamic Host Configuration Protocol&#xff0c;动态主机配置协议&#xff09;网关配置DHCP服务器配置如果没有DHCP服务器&#xff0c;只在网关上做DHCP服务器&#xff1a; DHCP&#xff08;Dynamic Host Configuration Protocol&#xff0c;动态主…...

【ISO 14229-1:2023 UDS诊断(ECU复位0x11服务)测试用例CAPL代码全解析④】

ISO 14229-1:2023 UDS诊断【ECU复位0x11服务】_TestCase04 作者&#xff1a;车端域控测试工程师 更新日期&#xff1a;2025年02月17日 关键词&#xff1a;UDS诊断协议、ECU复位服务、0x11服务、ISO 14229-1:2023 TC11-004测试用例 用例ID测试场景验证要点参考条款预期结果TC…...

llama.cpp将sensor格式的大模型转化为gguf格式

前言 ollama本地只能导入gguf格式的大模型文件&#xff0c;将safetensors 文件转化为gguf格式。需要使用 llama.cpp 这个开源工具。以下是使用 llama.cpp 转换 .safetensors 格式模型到 .gguf 格式的详细步骤: 1. 首先克隆并编译 llama.cpp: 克隆项目 git clone https://gi…...

Fastgpt学习(5)- FastGPT 私有化部署问题解决

1.☺ 问题描述&#xff1a; Windows系统&#xff0c;本地私有化部署&#xff0c;postgresql数据库镜像日志持续报错" data directory “/var/lib/postgresql/data” has invalid permissions "&#xff0c;“ DETAIL: Permissions should be urwx (0700) or urwx,gr…...

【Linux AnolisOS】配置Linux固定ip地址。然后在Windows上连接使用linux中docker容器里的redis和nacos。

1.关于将虚拟机ip地址更改为静态地址 &#xff0c;跟着下面这个视频搞的&#xff0c;不想看文章的可以看视频。 第四章-07-配置Linux固定IP地址哔哩哔哩bilibili 当用的centos9 视频里让我们打开网络配置文件 vim /etc/sysconfig/network-scripts/ifcfg-ens33 但是我打开时…...

Linux应用之构建命令行解释器(bash进程)

目录 1.分析 2.打印输入提示符 3.读取并且处理输入字符串 4.创建子进程并切换 5.bash内部指令 6.完整代码 1.分析 当我们登录服务器的时候&#xff0c;命令行解释器就会自动加载出来。接下来我们就。在命令行中输入指令来达到我们想要的目的。 我们在命令行上输入的…...

挪车小程序挪车二维码php+uniapp

一款基于FastAdminThinkPHP开发的匿名通知车主挪车微信小程序&#xff0c;采用匿名通话的方式&#xff0c;用户只能在有效期内拨打车主电话&#xff0c;过期失效&#xff0c;从而保护车主和用户隐私。提供微信小程序端和服务端源码&#xff0c;支持私有化部署。 更新日志 V1.0…...

DockerDesktop更改默认的磁盘镜像地存储位置

DockerDesktop更改默认的磁盘镜像地存储位置 文章目录 DockerDesktop更改默认的磁盘镜像地存储位置1. 默认存储位置2. 新建一个目录3. 将磁盘镜像存储位置改为新建的目录下 1. 默认存储位置 2. 新建一个目录 如&#xff1a;D:\DiskImagelocationData 3. 将磁盘镜像存储位置改为…...

[数据结构]顺序表详解

目录 一.线性表 二.顺序表 2.1概念及结构 1. 静态顺序表&#xff1a;使用定长数组存储元素。 2. 动态顺序表&#xff1a;使用动态开辟的数组存储。 2.1按需申请 2.2 接口实现&#xff1a;增删查改 SeqList.h: SeqList.c: test.c 一.线性表 线性表 &#xff08; line…...

GO语言的安装以及第一个Go语言程序

1. Go语言的安装与设置 官网:golang.org 国内下载:https://studygolang.com/dl 国内镜像:https://goproxy.cn/ 2. GOland的安装 Go 1.13 及以上&#xff08;推荐&#xff09; 打开你的终端并执行 $ go env -w GO111MODULEon $ go env -w GOPROXYhttps://goproxy.cn,direc…...

SpringBoot速成(12)文章分类P15-P19

1.新增文章分类 1.Postman登录不上&#xff0c;可以从头registe->login一个新的成员:注意&#xff0c;跳转多个url时&#xff0c;post/get/patch记得修改成controller类中对应方法上写的 2.postman运行成功&#xff1a; 但表中不更新&#xff1a;细节有问题&#xff1a; c是…...

notepad++右键菜单不见了

卸载时没点击完成&#xff0c;又重新安装了一个&#xff0c;最终导致了一些bug&#xff0c;导致右键没有notepad菜单。 解决方式&#xff1a; 新建一个register.reg文件&#xff0c;加入以下代码&#xff0c;然后双击执行即可 代码说明&#xff1a;Open with Notepad 是右…...

Spring 接入 DeepSeek

引入依赖 <dependency><groupId>org.springframework.ai</groupId><artifactId>spring-ai-openai-spring-boot-starter</artifactId> </dependency>2.yml配置 spring:ai:openai:api-key: sk-xxxxx // 填写自己申请的keybase-url: http…...

开题报告——基于Spring Boot的社区居民健康管理平台的设计与实现

关于本科毕业设计(论文)开题报告的规定 为切实做好本科毕业设计(论文)的开题报告工作,保证论文质量,特作如下规定: 一、开题报告是本科毕业设计(论文)的必经过程,所有本科生在写作毕业设计(论文)之前都必须作开题报告。 二、开题报告主要检验学生对专业知识的驾…...

(leetcode42 前缀后缀最值)接雨水

记忆化&#xff1a;打比方说前缀和 dp数组每个值代表了某一段计算过程 直接取值无需再计算就是记忆化 问题的核心思路 为了计算每个位置能接住多少水&#xff0c;我们需要知道在每个位置上方的水的容量。假设位置 i 是某个柱子的底部&#xff0c;要计算它能接多少水&#xff…...

SpringBoot+uniApp日历备忘录小程序系统 附带详细运行指导视频

文章目录 一、项目演示二、项目介绍三、运行截图四、主要代码1.日历渲染代码&#xff1a;2.保存备忘录代码&#xff1a;3.删除备忘录代码&#xff1a; 一、项目演示 项目演示地址&#xff1a; 视频地址 二、项目介绍 项目描述&#xff1a;这是一个基于SpringBootuniApp框架开…...

分类预测 | MFO-LSSVM飞蛾扑火算法优化最小二乘支持向量机多特征分类预测Matlab实现

分类预测 | MFO-LSSVM飞蛾扑火算法优化最小二乘支持向量机多特征分类预测Matlab实现 目录 分类预测 | MFO-LSSVM飞蛾扑火算法优化最小二乘支持向量机多特征分类预测Matlab实现分类效果基本介绍程序设计参考资料 分类效果 基本介绍 1.Matlab实现MFO-LSSVM飞蛾扑火算法优化最小二…...

Linux 和 Windows 区别

1. 文件组织 (1)目录结构 Linux:采用**单一根目录(/)**结构,所有文件和设备都挂载在这个目录下。 典型目录: /home/(用户目录)/etc/(配置文件)/bin/(系统可执行文件)/dev/(设备文件)/mnt/(挂载点)Windows:采用多个驱动器(C:\, D:\),每个分区是一个独立的…...

Android - Handler使用post之后,Runnable没有执行

问题&#xff1a;子线程创建的Handler。如果 post 之后&#xff0c;在Handler.removeCallbacks(run)移除了&#xff0c;下次再使用Handler.postDelayed(Runnable)接口或者使用post时&#xff0c;Runnable是没有执行。导致没有收到消息。 解决办法&#xff1a;只有主线程创建的…...

vscode通过ssh连接服务器实现免密登录+删除

文章目录 参考&#xff1a; 1、 vscode通过ssh连接服务器实现免密登录删除&#xff08;吐血总结&#xff09;...

Redis未授权访问漏洞原理

redis未授权访问漏洞 目录 redis未授权访问漏洞一、Redis介绍二、redis环境安装三、漏洞原理四、漏洞复现4.1 webshell提权4.2redis写入计划任务反弹shell4.3 ssh key免密登录4.4 Redis基于主从复制的RCE方式 五、Redis加固建议 一、Redis介绍 Redis&#xff0c;全称为Remote …...

喜报!博睿数据案例获经观传媒“2024年度数字转型创新案例”!

本文已在“经观”APP中发表&#xff0c;点击下方文章链接查看原文&#xff1a; 2024科技创变纪&#xff1a;创新破局 变量启新 近日&#xff0c;经济观察报“2024年度卓越创新实践案例”榜单评选结果正式公布。博睿数据选送的案例“从零到一&#xff1a;可观测体系建设的探索…...

【从0做项目】Java搜索引擎(4)——性能优化~烧脑~~~

本篇文章将对项目搜索引擎&#xff08;1&#xff09;~&#xff08;3&#xff09;进行性能优化&#xff0c;包括测试&#xff0c;优化思路&#xff0c;优化前后对比 目录 一&#xff1a;文件读取 二&#xff1a;实现多线程制作索引 1&#xff1a;代码分析 2&#xff1a;代码…...

什么是网络安全审计?网络安全审计的作用...

网络安全审计通过对网络数据的采集、分析、识别&#xff0c;实时动态监测通信内容、网络行为和网络流量&#xff0c;发现和捕获各种敏感信息、违规行为&#xff0c;实时报警响应&#xff0c;全面记录网络系统中的各种会话和事件&#xff0c;实现对网络信息的智能关联分析、评估…...