Giter Club home page Giter Club logo

lua's Introduction


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)

lua's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.