0.0.1-5 • Published 12 years ago
luvit-set v0.0.1-5
#luvit-set Straightforward Lua Set library for Luvit
##Install
- Download and install Node.js. Then you have
npm - In the root of your Luvit project,
npm install luvit-set
##Usage Start off with
local Set = require("luvit-set")Then, to create a set (of things you like):
local ilike = Set:new()to add items to a set:
ilike:add("apples")
ilike:add("bananas")or, initialise with values on creation:
local ilike = Set:new({"apples", "bananas"})Let's create another set:
local ulike = Set:new({"apples", "strawberries"})Then we can:
local welike = ilike + ulike -- union: apples, bananas, strawberries
local webothlike = ilike * ulike -- intersection: apples
local udontlike = ilike - ulike -- subtraction: bananasLastly, some conveniences:
local somethingilike = ilike:anelement()
ilike:len() -- 2
for k, _ in pairs(ilike) do
print(k)
end
print(ilike) -- '{"apples", "bananas"}'
local list = ilike:tolist() -- {"apples", "bananas"}##Tests
npm test luvit-set
##License
LGPL+; see the LICENSE file