|
Am 01.07.2015 um 04:44 schröbte Siddhartha Jain:
Hi,
Hi!
I'm trying to find a hash map for Lua that can be indexed by a tuple. I
thought I had found it in sano but there seems to be something wrong with
the code that is online -- I'm getting errors if I run it in lua or luajit
(the offending function[1] is below)
So any suggestions for alternatives and/or suggestions to fix sano would be
most welcome :)
How about this one:
http://siffiejoe.github.io/lua-multikey/
If you only need it for memoization, there are some more candidates at the bottom of this page:
http://lua-users.org/wiki/FuncTables
Thanks!
--Sid
Philipp
[1] local function memoizedKnownArgs(func, numArgs)
local results = {}
if numArgs == 1 then
return function(...)
local t = results*[arg[1endlongstringliteral*
if t == nil then
t = func(arg[1])
results*[arg[1endlongstringliteral* = t
end
return t
end
else
error("only works for memoizing 1 param functions")
end
end