lua学习笔记day02-----类型,值,运算符

手把手教你用TUSB2E22中继器实现eUSB2与USB 2.0互转(附实测数据对比) 本文详细介绍了如何利用TUSB2E22中继器实现eUSB2与USB 2.0的高效互转,包括技术背景、硬件设计要点、信号完整性测试方法及故障排查策略。通过实测数据对比,展示了TUSB2E22在信号延迟、功耗和眼图性能上的显著优势,为工程师提供了实用的工程方案。 阅读详情

第2章 类型和值

nil、boolean、number、string、userdata、function、thread和table

nil:这种类型至于一个值,那就是nil。如果一个变量的值是nil,那么这个变量就不存在(不是为空,而是不存在)。所以当对一个变量赋值为nil时,也就是不要这个变量了。

boolean:有两种值,false、true。在lua中,变量结果为false只有两种情况,false、nil。即使是0都是true

nubmer:实数,不区分整数和小数,代表所有的数。

string:字符串。可以存放非常大的字符串,有1M的。

function:lua中认为函数是第一类值,是可以像其他参数一样。

userdata:用来存放c语言数据,具体使用,后续再看。


string类,有一些其他的操作。当string类型碰到算术运算符的时候,会变成number类型。当number碰到字符链接符(..)的时候,会变成string类型。

还有可以用 tostring(value)、tonumber(value)这样的函数来转换。


第3章 运算符

算数运算符 :类似 +、-、*、/还有 - 都是给实数运算用的


关系运算符 :<、>、<=、>=、==、~= ,返回的结果只有两种,true、false

比较number时,规则时传统的比大小规则。

比较string时,从首字母开始按照字母顺序进行,靠后的比较大。"abc"<"abcd"

混合string和number比较的时候,lua会报错。ps:”2“>15


逻辑运算符 :and or not

A and B :A为false时,结果为A,否则结果为 B

A or B :A为ture时,结果为A,否则结果为B

and的优先级比or高

A?B:C

A and B or C

上述两者时等价的。


连接运算符 :..

用于连接字符串,A..B  --> AB

当连接字符串两端有number类型时,会自动转换成string类型


优先级 :

^
not  - (unary)
* /
+ -
..
< > <= >= ~= ==
and
or



YOLO系列算法改进 | C3k2改进篇 | 融合DEConv细节增强卷积模块 | 细节增强+多分支差分卷积融合,标准卷积的完美涨点替代! | TIP 2024 YOLO系列算法改进 | C3k2改进篇 | 融合DEConv细节增强卷积模块 | 细节增强+多分支差分卷积融合,标准卷积的完美涨点替代! | TIP 2024 (以YOLO26最新目标检测模型为基础,融合C3k2_DEConv创新模块进行改进) 阅读详情

相关推荐

Halcon与C#联合编程(一):使用S7协议实现机器视觉上位机与西门子PLC联动

本项目技术栈:C#基础,多线程,Halcon DirectShow,Halcon形状检测,Halcon QR码识别,西门子S7通讯协议,西门子PLC为核心的下位机及执行元件

虎鲸不是鱼 1万+

Lua基本知识

打印 print"Hello World!" print("Hello World") 注释 单行注释 -- 多行注释 --[[]] 字符串 a="String" a=[[String]] a=[===[String]===] 赋值 a="Hello World" --lua支持多重赋值 a,b="String a","String b" --交换值 a,b="String a","...

bmzk123的博客 418

java实现mavlink协议解析与封包上传数据,实现mavlink数据交互,附带代码、详解

本篇文章介绍了使用java来进行mavlink协议解析,封包与解包的过程,并附带源码供大家使用。MAVLink(Micro Air Vehicle Link,微型空中飞行器链路通讯协议)是无人飞行器与地面站(Ground Control Station ,GCS)或云端服务器之间通讯,以及无人飞行器之间通讯最常用的协议。它已经在PX4、APM、PIXHAWK和Parrot AR.Drone飞控平台上进行了大量测试。

qq_30279827的博客 1460

Lua变量判断空

Lua变量判断空

3467

【Coze 扣子案例】第 23 期・商业篇:一键获取精准商机,自动化招标信息查询与分析

通过地区和项目类型等多维度组合查询全国招标信息网数据,实现招标公告的快速定位。自动解析招标公告内容,提取关键信息,并生成结构化摘要。帮助企业高效获取精准商机,提升市场竞争力,降低人工成本,解决 “信息过载” 与 “精准匹配难” 的双重问题。

weixin_72689845的博客 1935

Android15音频进阶之音效配置与解析(一百三十一)

本篇目的:Android15音频进阶之音效配置与解析。

Android系统攻城狮 2152

Lua 基础知识

Lua 基础语法知识整理

weixin_54955442的博客 1466

SAP 发票凭证反向冲销

发票凭证反向冲销: 业务模拟: MIRO发票校验后,生成发票凭证号: 事务代码MR8M,输入凭证号码,反向冲销(类似于MIGO入库后的反向冲销): 此时进入MIRO查看,发现冲销成功,可以再次做MIRO发票校验: ...

willieyuan的博客 7722

初出茅庐的小李第79篇博客之Lua学习笔记第6篇(Lua判断语句)

Lua语言表示逻辑关系的关键字 and 表示与逻辑 or 表示或逻辑 not 表示非逻辑 Lua语言表示逻辑真假的关键字 true 表示真 false 表示假 布尔类型(boolean)只有两个可选值:(true真)和false(假) Lua中关于假的定义 仅仅只有false 和 nil 表示假 Lua中关于真的定义 只要不是假的都表示真 既是出去false 和nil 之外的所有结果都是真 Lua中的关系运算符 符号 结果 == 测试等于,检测两个值是

初出茅庐的小李 485

2022年12月机器人技术等级考试试卷(三级实操) 试题解析

2022年12月机器人技术等级考试试卷(三级实操) 试题解析

http://www.cierobot.com 1527

一套适合 ABAP 初级和中级开发人员,从入门到提高的 ABAP 学习教程

曾几何时,ABAP 就是 SAP 的代名词。ABAP 这门编程语言造就了 SAP 名噪一时的 R/3 产品,同时也是如今 SAP 旗舰级产品,SAP S/4HANA 底层的实现语言。 ABAP 不仅代表着 SAP 这家公司在企业级管理软件市场辉煌的过去,ABAP 自身也在不断地进化着。SAP 不仅在本地部署(On-Premise)领域继续保持着自己绝对的统治地位,而且在云应用领域(Software-as-a-Service, 简称 SaaS), 也推出了自己的解决方案,比如 SAP S/4HANA Clo

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 6005

lua学习之类型与值篇

类型与值 lua 是动态类型的语言 在语言中没有类型定义的语法 每个值都携带有它的类型信息 8种基础类型 用 type 可以返回这个值的类型的名称 将一个变量用于不同类型,通常会导致混乱的代码 但合理使用,如异常情况下返回 nil ,以区别正常情况下的其他类型的返回值 变量没有预定义的类型,任何变量都可以包含任何类型的值 print(type("Hello")) --string print(type(666)) --number a = print print(type(a)) --func...

imherer的博客 609

《备考系统架构设计师》 - 专栏介绍和目录

本专栏包括所有历年真题及详解、章节知识核心总结、精选高分论文、补充知识、专题总结等。欢迎订阅专栏。

数据知道的博客 4万+

Lua学习笔记之lua基本语法DAY1

1注释: ①单行注释:两个减号是单行注释。 eg. -- ②多行注释:--[[多行注释 多行注释 ]]-- 2.标示符:Lua标示符用于定义一个变量,函数获取其他用户定义的项。标示符以一个字母A到Z或a到z或下划线_开头后加上0个或多个字母、下划线、数字(0到9). Lua不允许使用特殊字符如@,$和%来定义标示符。Lua是一个区分大小写的编程预言。 3.关键字:以下列

学习学习再学习 387

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

Lua语法!(上篇)

在我们编写代码之前,需要做一下准备,就是:确保你输入标点符号时,用的不是中文输入法。

HFL2023901的博客 941

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Lua语法基础全面剖析(上篇)

今天我们来进行Lua语法全面剖析。 由于篇幅过长,将分为上中下三篇进行讲解,本篇为上篇。 1.初识Lua Lua 是一种轻量小巧的脚本语言,它用标准C语言编写并以源代码形式开放。

yangliu123456_的博客 1020

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

Lua学习笔记-day3:函数、运算符

一、Lua函数 1. 函数定义: optional_functoin_scope function function_name(arg1, arg2, arg3,...,argn) function_body return ret1,ret2,...,retn end   1.1 说明: ...

HappyMrSpring 229

十分钟学会Lua语法基础教程(上篇)

Lua 是一种轻量小巧的脚本语言,它用标准C语言编写并以源代码形式开放。这意味着什么呢?这意味着Lua虚拟机可以很方便的嵌入别的程序里,从而为应用程序提供灵活的扩展和定制功能

2401_87506083的博客 901

必知的Lua语法:编程秘籍在此(上篇)

在目前脚本引擎中,Lua的运行速度占有绝对优势。这些都决定了Lua是作为嵌入式脚本的最佳选择。 在我们编写代码之前,需要做一下准备,就是:确保你输入标点符号时,用的不是中文输入法。

hellowordh1的博客 862

我宣布!这就是全网最全的Lua语法基础教程【上篇】

今天,我把教程分为上中下三篇进行讲解,本篇为上篇。一大家起学起来吧~

UpUpStudy123的博客 1058

一定不能错过!Lua语法基础教程【上篇】新手必学!

本文介绍了Lua的基础语法,包括数据类型、变量、循环、条件控制、函数和表。这些基础知识是进一步学习Lua的重要基石。由于篇幅过长,将分为上中下三篇进行讲解,本篇为上篇。快快学起来吧~

2401_87501795的博客 652

开发必学!Lua语法基础教程(上篇),一定要看~

本文将带您快速入门Lua语言,探索其基本语法特性和核心概念。

2401_87501788的博客 895

还不会使用Lua语言吗?基础教程手把手教会!

Lua虚拟机可以很方便的嵌入别的程序里,从而为应用程序提供灵活的扩展和定制功能。而整个Lua虚拟机编译后仅仅一百余K,经过适当的裁剪还能做到更小,十分适合嵌入式的开发。目前脚本引擎中,Lua的运行速度占有绝对优势。今天我们来学习Lua语法基础教程。由于篇幅过长,将分为上中下三篇进行讲解,本篇为上篇。在我们编写代码之前,需要做一下准备,就是:确保你输入标点符号时,用的不是中文输入法。

m0_57476762的博客 926

最简单Lua语法教程,看了就会!(上篇)

你得知道,看了本教程,Lua语法也就了解了90%呢!学习Lua语法篇幅太长,我将分为上中下三篇贴出,本篇为上篇。

Nizi2007的博客 955

学Lua语法,涨知识!(上篇)

我将为大家带来上中下三篇关于Lua语法的文章,希望大家能对其有新的认识。

LuatOS的博客 910

lua笔记

目录 string(字符串)字符串由一对双引号或单引号来表示。 Table(表) function (函数) while 循环 for 循环 数值for循环 泛型for循环 运算符 关系运算...

dichong6201的博客 136
上一篇: lua学习笔记day01
下一篇: lua学习笔记day02-----table
displayMessage
博客等级 码龄11年 34粉丝 114原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址