lua: Learning Official Doc notes

dynamically typed vars:

basic types: nil, boolean, number, string, function, userdata, thread & table.

where nil has only one value, is mainly to differ from other types. absense of useful info

bool: false & true. so false & nil are both make a conditional false

number: int & floating point, 2 subtypes, rules to when to use which. also converting automatically, standard lua use 64-bit num. but can re-compile lua to use 32bit. (see luaconf.h

string: immutable sequence of bytes, containing all info in 8-bit value. encoding-agnostic (nice !

calling functions written in lua/c.

userdata: store any c data. raw memory. 2 kinds of userdata: full userdata: object; light userdata: pointer value. this type of data has no predefined ops, only to assign or identity test. It cannot be created or modifiied in lua. only through C api. guarentees the integrity. But using metatables, user can define ops for full userdata.

thread: represents independent threads of execution and used to implement coroutines. its not same as os‘s threads... coroutines are supported on all systems. even on no thread systems..

table: assoc. arrays. map? yes. with tables, arrays can be indexed through values other than numbers, but not nil or NaN. where NaN is actually number typed and to represent INF. but the key value can be anything except nil.. pathetic.. and conversely.. very odd.. any key not belonging to a table has an associated value nil. a.name is equal to a["name"]. -- syntax sugar

sequence

concept: equal without metamethods.. a.i, a.j refer to the same obj iff. i, j EWM. however, a.2 and a.2.0 refer to the same obj.. because float value which is actually a int will be automatically convert to the int.. so a.2.0 is actually a.2 .. table fields can be of any type.. including functions, tables can carry methods

tables, functions, threads, full userdata values are objs and refer to the address where locates. functions manipulate these refs only return the refer to these values, not modifying

function: type(), this returns a string describing the type of value..

时间: 2024-12-22 00:38:13

lua: Learning Official Doc notes的相关文章

<YaRN><Official doc><RM REST API's>

Overview ... YARN Architecture The fundamental idea of YARN is to split up the functionalities of resource management and job scheduling/monitoring into separate daemons. [基本思想是将资源管理和任务调度/监控分开.] The idea is to have a global ResourceManager(RM) and pe

Machine Learning Algorithms Study Notes(3)--Learning Theory

Machine Learning Algorithms Study Notes 高雪松 @雪松Cedro Microsoft MVP 本系列文章是Andrew Ng 在斯坦福的机器学习课程 CS 229 的学习笔记. Machine Learning Algorithms Study Notes 系列文章介绍 3 Learning Theory 3.1 Regularization and model selection 模型选择问题:对于一个学习问题,可以有多种模型选择.比如要拟合一组样本点,

Machine Learning Algorithms Study Notes(2)--Supervised Learning

Machine Learning Algorithms Study Notes 高雪松 @雪松Cedro Microsoft MVP 2    Supervised Learning    3 2.1    Perceptron Learning Algorithm (PLA)    3 2.1.1    PLA -- "知错能改"演算法    4 2.2    Linear Regression    6 2.2.1    线性回归模型    6 2.2.2    最小二乘法( le

Machine Learning Algorithms Study Notes(1)--Introduction

Machine Learning Algorithms Study Notes 高雪松 @雪松Cedro Microsoft MVP 目 录 1    Introduction    1 1.1    What is Machine Learning    1 1.2    学习心得和笔记的框架    1 2    Supervised Learning    3 2.1    Perceptron Learning Algorithm (PLA)    3 2.1.1    PLA -- "知

Machine Learning Algorithms Study Notes(4)—无监督学习(unsupervised learning)

1    Unsupervised Learning 1.1    k-means clustering algorithm 1.1.1    算法思想 1.1.2    k-means的不足之处 1.1.3    如何选择K值 1.1.4    Spark MLlib 实现 k-means 算法 1.2    Mixture of Gaussians and the EM algorithm 1.3    The EM Algorithm 1.4    Principal Components

Machine Learning Algorithms Study Notes(5)—Reinforcement Learning

Reinforcement Learning 对于控制决策问题的解决思路:设计一个回报函数(reward function),如果learning agent(如上面的四足机器人.象棋AI程序)在决定一步后,获得了较好的结果,那么我们给agent一些回报(比如回报函数结果为正),得到较差的结果,那么回报函数为负.比如,四足机器人,如果他向前走了一步(接近目标),那么回报函数为正,后退为负.如果我们能够对每一步进行评价,得到相应的回报函数,那么就好办了,我们只需要找到一条回报值最大的路径(每步的回

LUA Learning Note 6: 元表与元方法

--元表:是用来存放无方法的一个table. --table和userdata可以各种拥有独立的元表. 但是,其他类型的值就只能共享其类型所属的元表,比如,数字,所有的数字都共用一个元表. --元方法:用来进行table 类型变量进行特殊操作的一个方法. --Lua其实已经规定好了各种算术操作符的元方法名字:_add,_sub,_mul,_div,_unm,_mod,_pow. --使用步骤: -- 创建一个元表     local mt = {};     mt.__add = functio

learning yaffs2 filesystem notes

参数inband_tags就表示tags存放的位置,tags的大小为16字节,其定义如下所示. struct yaffs_packed_tags2_tags_only { unsigned seq_number; unsigned obj_id; unsigned chunk_id; unsigned n_bytes; }; inband_tags参数的值为0时,表示tags存放在Flash页的OOB区域内, 值为1时,表示tags存放在Flash页的数据区域内, 值得注意的是,对于页大小为51

CentOS下配置Lua运行环境

Warning: 本文原网页 http://www.centoscn.com/yunwei/Lua/2013/0817/1284.html 在此基础上略作修改,如有侵权,请告知删除,谢谢! 在正式操作前请获得root权限! 1.下载包 [[email protected] ~]# wget http://www.lua.org/ftp/lua-5.3.1.tar.gz 2.解压缩 [[email protected] lua]# tar zxf lua-5.3.1.tar.gz 3.修改Make