Giter Site home page Giter Site logo

lua-table's Introduction

lua-table

Lua-Table 0.7

Lua tables with superpowers ๐Ÿ’ช

Changes

View the changelog for more info about changes.

Installation

To install the library just clone the repo or install via LuaRocks.

Examples

-- load library
local table = require "luatable"

-- create a normal table
local t = { 1, 2, 2, 3, -4, 5 }

-- remove negative values
t = table.accept(t, table.positive)

-- create an enhanched table from an old one
local tb = table(t)

-- print every element
tb:eachi(print)

-- or print the entire table (with key-value pairs)
print(tb)

-- double and sum values
local sum = tb:map(table.double):reduce(0, table.sum)

-- remove duplicates
tb = table.unique(tb)

-- clear and add values to table
tb:clear()
tb:append(4, 5, 6)
tb:push(1, 2, 3)

-- table equality
local t1 = { 1, 2, 3, x = { 4, 5 } }
local t2 = { 1, 2, 3, 4, 5 }

print(table.equal(t1, t2))       --> false
print(table.equal(t1, t2, true)) --> true

-- operator overloads
local t1 = table { 1, 2, 3 }
local t2 = table { 2, 4, 5 }

print(t1 + t2)  -- table.union
print(t1 - t2)  -- table.negation
print(t1 * t2)  -- table.intersect
print(t1 == t2) -- table.equal
print(t1 .. t2) -- table.merge

lua-table's People

Contributors

luca96 avatar reallinfo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

reallinfo gsdenys

lua-table's Issues

Logo contribution

Hello @Luca96 , I am graphic designer. I like to contribute to open source software. So i designed a logo for lua-table. I combined a tablo and the lua logo. If there is your another idea, feel free to say me. What do you think about this logo?

luatable

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.