Haha, it's about the bug of the set Module of the Lua stdlib library. In fact, the author seems to have confirmed it for a long time .... But I haven't accessed Gmail for a while, so I didn't see it... The author said that this bug has been modified in the new version... and the latest version is released today. I found this is true: Haha, I am so glad that it has absorbed so much nutrition from the open-source community... I have finally paid off a little... Of course, this is just the start :)
Paste the actual process... Satisfying vanity... In fact, it is just a very small bug that can be easily discovered... I learned Lua only a week or two .. It is impossible to find a difficult bug... LOL
A program in the original Lua stdlib set is as follows:
- -- @ Func propersubset: Find whether one set
Is
A proper subset
- -- Another
- -- @ Param S, T: Sets
- -- @ Returns
- -- @ Param R: True
If
S
Is
A proper subset of T, false otherwise
- Function propersubset (S, T)
Return
Subset (S, T)
And
Not
Subset (t, s)
- End
- -- @ Func equal: Find whether two sets are equal
- -- @ Param S, T: Sets
- -- @ Returns
- -- @ Param R: True
If
Sets are equal, false otherwise
- Function equal (S, T)
Return
Subset (S, T)
And
Subset (S, T)
- End
- -- @ Head metamethods
For
Sets
- -- Set + Table = Union
- Retriable. _ add = Union
- -- Set-table = set difference
- Retriable. _ sub = difference
- -- Set/table = Intersection
- Retriable. _ DIV = Intersection
- -- Set <= table = subset
- Retriable. _ LE = subset
So I sent an email to the author.
Hi all,
Thank you very much for your hard working with the luaforwindows, I enjoy it so mush.
There is a bug to report as my return.
The set. Lua file in the lualibs, 117th line.
Source as this Code: "Return subset (S, T) and subset (S, T )"
It obviusly shocould be "Return subset (S, T) and subset (t, s )"
Which means they are equal when S is the subset T and T is the subset S.
I hope I'm right and didn't disturb you.
BTW, there is a surprising attribute.
In the set's operations, Div (/) mean intersection that is different from custom.
In the custom MUL (*) denotes it, just like the <programming in Lua> writes in the 13th captial named "retriable and meatmethod"
Thank you for reading my poor Chinglish. Lol, I'm Chinese.
Best wishes.
Your honest
Jtianling from jtianling {at} gmail.com
Reply from luaforwindows author
Andrew Wilson to me, RRT, luaforwindows
Show Details Sep 3 reply
Thanks for the bug report jtianling, this particle module comes from
The stdlib library, I'll copy your report of this issue to
Administrator of that project http://luaforge.net/projects/stdlib/
.
Your English is great, you wouldn't want to even hear my Mandarin.
Concern
Andrew Wilson
Well, I don't know what he meant here .... He really can play Chinese characters .... E-text system should have no Chinese input method ....
Finally, the author of Lua stdlib replied:
Reuben Thomas to Andrew, me, luaforwindows
Show Details Sep 4 reply
Thanks, this is quite correct. I 've made a new release with this fix.
I see, I had actually forgotten that * is used in Modula-3 in the same way. I am happy to change this so that * is intersection and/is unsupported Ric difference.
Thanks, I 've made another release with these changes, and coincidentally fixed set. difference, which was also broken.
Haha, the latest version of set is as follows. It can be seen that it has been fixed, and even the "/" symbol that I call the surprising attribute indicates that the intersection is also changed :)
- -- @ Func intersection: Find the intersection of two sets
- -- @ Param S, T: Sets
- -- @ Returns
- -- @ Param R: set intersection of S
And
T
- Function intersection (S, T)
- Local r = new {}
For
E
In
Elements (s) do
If
Member (T, E) then
- Insert (R, E)
- End
- End
Return
R
- End
- -- @ Func Union: Find the union of two sets
- -- @ Param S, T: Sets
- -- @ Returns
- -- @ Param R: set union of S
And
T
- Function Union (S, T)
- Local r = new {}
For
E
In
Elements (s) do
- Insert (R, E)
- End
For
E
In
Elements (t) Do
- Insert (R, E)
- End
Return
R
- End
- -- @ Func subset: Find whether one set
Is
A subset of another
- -- @ Param S, T: Sets
- -- @ Returns
- -- @ Param R: True
If
S
Is
A subset of T, false otherwise
- Function subset (S, T)
For
E
In
Elements (s) do
If
Not
Member (T, E) then
Return
False
- End
- End
Return
True
- End
- -- @ Func propersubset: Find whether one set
Is
A proper subset
- -- Another
- -- @ Param S, T: Sets
- -- @ Returns
- -- @ Param R: True
If
S
Is
A proper subset of T, false otherwise
- Function propersubset (S, T)
Return
Subset (S, T)
And
Not
Subset (t, s)
- End
- -- @ Func equal: Find whether two sets are equal
- -- @ Param S, T: Sets
- -- @ Returns
- -- @ Param R: True
If
Sets are equal, false otherwise
- Function equal (S, T)
Return
Subset (S, T)
And
Subset (t, s)
- End
- -- @ Head metamethods
For
Sets
- -- Set + Table = Union
- Retriable. _ add = Union
- -- Set-table = set difference
- Retriable. _ sub = difference
- -- Set * Table = Intersection
- Retriable. _ Mul = Intersection
- -- Set/table = distributed Ric difference
- Retriable. _ DIV = effecric_difference
- -- Set <= table = subset
- Retriable. _ LE = subset
- -- Set <Table = proper subset
- Retriable. _ lt = propersubset
Although this is a trivial matter like sesame, it is my first real contribution to the open-source community .... Although it is only in the form of a bug report :)