tuple is a library that provides support for internalized tokens that represent a tuple of Lua values.

	local tuple = require("tuple").create
	
	local map = {}

	map[tuple(1,2,3)         ] = "1,2,3"
	map[tuple("A","B","C")   ] = "A,B,C"
	map[tuple(true,map,false)] = "true,map,false"
	map[tuple({},{},{})      ] = "{},{},{}"

	assert(map[tuple(1,2,3)         ] == "1,2,3")
	assert(map[tuple("A","B","C")   ] == "A,B,C")
	assert(map[tuple(true,map,false)] == "true,map,false")
	assert(map[tuple({},{},{})      ] == nil) -- is another tuple

	map[tuple(1,2,3)         ] = nil
	map[tuple("A","B","C")   ] = nil
	map[tuple(true,map,false)] = nil

	local key = next(map)
	local v1, v2, v3 = key()
	assert(type(v1) == "table")
	assert(type(v2) == "table")
	assert(type(v3) == "table")
	map[key] = nil
	assert(next(map) == nil) -- table is empty again!

Download

You can install Tuple through LuaRocks using the following command.

   luarocks install tuple

This library is provided as free software under the terms of the MIT License, which are the same terms of the Lua License.

For download see the list of released packages.

Author

This project was created by Renato Maia.

Copyright (C) 2014 Tecgraf, PUC-Rio

This project is currently being maintained by Tecgraf at PUC-Rio.