lua-users home
lua-l archive

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

I was looking for priority queue and found this implementation on
Rosetta Code (Lua implementation):

Or I am doing something really stupid or that Lua implementation is not
right. I mean it passes all assertion when i copy/paste and run the
code. But when i change the test code a little it breaks.
If I change n and m parameters in such way that m > n
assertion fails.
Also  if I insert a line
in test then assersion fails too.

I think author is expecting that this line in pop function
            for p, q in pairs(self) do
will return elements sorted by p (and to make things interesting, in
some cases it does).

Anybody care to replace that code for good one?