lua-users home
lua-l archive

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


On Wed, Feb 15, 2012 at 12:40 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> Personally I prefer a multiset aka histogram: instead of `s[v]=true`,
>    s[v] = (s[v] or 0) + 1

And with

s = setmetatable({},{__index = function(t,k) return 0 end})

you can reach notational nirvana

s[v] = s[v] + 1

steve d.