eonblast / lua Goto Github PK
View Code? Open in Web Editor NEWLua 5.2 with true length count for tables
Lua 5.2 with true length count for tables
This is Lua 5.2 (alpha), released on 23 Nov 2010 with a hack for true count of table and string sizes. as of 06 Jan 2011. THIS IS NOT A STANDARD LUA INSTALLATION. Please go to http://www.lua.org/download.html for that. For installation instructions, license details, and further information about Lua, see doc/readme.html. Use: Use the % operator to retrieve the actual number of elemets in a table that are not 'nil'. t = {'foo', nil, 'bar'} print(%t) Or to get an estimate about how many printable characters a UTF-8 string has. Compare this with #t. Of course, instead of '%' we might want to have a function. Basic direction: git clone [email protected]:Eonblast/Lua.git lua52 cd lua52 sudo make <your os> install src/lua test/len.lua src/lua test/strlen.lua Implementation: The count is updated with every table update and therefore takes no time when called. The diff to Lua 5.2.2.0 alpha can be seen here https://github.com/Eonblast/Lua/compare/Lua_5.2.2.0_alpha_original...master Contact: [email protected] Samples: See test/len.lua and test/strlen.lua All these samples work fine, they are taken from the above files, there are many more. -- # # # # # # # # # # # # # # # # # # # # # # # # # Sparce amd Complete Lists -- # # # # # # # # # # # # # # # # # # # # # # # # # t = { } assert(t, 0) t = { nil, nil } assert(t, 0) t = { nil, nil, nil } assert(t, 0) t = { nil, 'foo', nil } assert(t, 1) t = { nil, nil, 'foo', nil , nil } assert(t, 1) t = { nil, nil, 'too', nil, nil, 'bar', nil, nil } assert(t, 2) -- # # # # # # # # # # # # # # # # # # # # # # # # # t = {} t[1] = 'foo' t[2] = nil t[3] = 'bar' assert(t, 2) t = {} t[1] = 'foo' t[2] = 'too' t[3] = 'bar' assert(t, 3) t = {} t[1] = nil t[2] = nil t[3] = 'bar' assert(t, 1) t = {} t[0] = 'foo' t[1] = 'too' t[2] = 'bar' t[-1] = nil assert(t, 3) -- # # # # # # # # # # # # # # # # # # # # # # # # # UTF-8 String Test Samples -- # # # # # # # # # # # # # # # # # # # # # # # # # assert("", 0) assert(" ", 1) assert("Q", 1) assert("Room", 4) assert("Tür", 3) assert("Dûnedaín", 8) assert("Stößel", 6) assert("Fu∂ark", 6) assert("«∑€®†Ω", 6) assert("黃耀賢 (Yau-Hsien Huang)", 21)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.