Yonaba / Moses

Utility library for functional programming in Lua

Home Page:http://yonaba.github.io/Moses

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

powerset does not generate a power set

hofstee opened this issue · comments

Despite its name, powerset does not actually create a power set. For example, the documentation states when given the set {1,2,3}, returns {{1},{2},{3},{1,2},{2,3},{1,2,3}} however the power set of {1,2,3} is actually {{},{1},{2},{3},{1,2},{1,3},{2,3},{1,2,3}}. Specifically {} and {1,3} are missing in this case.

Thanks @THofstee, good catch!

However, I cannot include this pull request, since the correct implementation you just provided is only valid with Lua 5.3 (it uses bit operators, which are not available with Lua 5.1 and Lua 5.2).

Since I want to preserve compatibility with previous versions of Lua, I will go with another proposal. Less faster though, but correct.