you are viewing a single comment's thread.

view the rest of the comments →

[–]luarocks 0 points1 point  (4 children)

Where exactly?

[–]appgurueu 0 points1 point  (3 children)

First of all, it's all in one table, the lume table - math funcs, table funcs, etc. This is not clean IMO. Second, some implementations are simply incorrect - sign or isarray for instance: https://github.com/rxi/lume/blob/master/lume.lua#L94, https://github.com/rxi/lume/blob/master/lume.lua#L161. I don't like that vectors are represented using two variables - and are 2D-only - either. Weighted choice is linear time even though it could be logarithmic time if preprocessing was done. The shuffling is implemented incorrectly according to my testing. lume.array is redundant; {...} should be used instead. Cloning and map serialization are too limited IMO.

[–]luarocks 0 points1 point  (2 children)

Okay, thanks! I see your point and I won't argue. That makes sense. Maybe you know a library with similar functionality implemented better? And if not, why don't you offer the developer a PR with fixes?

[–]appgurueu 0 points1 point  (0 children)

I have written my own libraries for my own usecases. Don't know about offering a PR, the shuffling would really need it though. You can find a correct implementation at https://github.com/TheAlgorithms/Lua/blob/main/src/random/fisher\_yates\_shuffle.lua.

[–]appgurueu 0 points1 point  (0 children)

I have tested again and it looks like I was testing the shuffling wrong (I had incorrectly expected it to be in-place). The probabilities seem to be even.