lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Thanks, the multikey library is adequate for my current purposes. Is there an alternative to sano in existence though -- sano seems to have a lot of nice collections with a nice interface that don't seem to be present elsewhere...

Best
--Sid

On Wed, Jul 1, 2015 at 5:32 AM, Philipp Janda <siffiejoe@gmx.net> wrote:
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