So happy .... Actually made a little contribution to the open-source business :), a bug in Lua stdlib that was pointed out a long time ago was confirmed.

Source: Internet
Author: User

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:

  1. -- @ Func propersubset: Find whether one set
    Is
    A proper subset
  2. -- Another
  3. -- @ Param S, T: Sets
  4. -- @ Returns
  5. -- @ Param R: True
    If
    S
    Is
    A proper subset of T, false otherwise
  6. Function propersubset (S, T)

  7. Return
    Subset (S, T)
    And
     
    Not
    Subset (t, s)
  8. End
  9. -- @ Func equal: Find whether two sets are equal
  10. -- @ Param S, T: Sets
  11. -- @ Returns
  12. -- @ Param R: True
    If
    Sets are equal, false otherwise
  13. Function equal (S, T)

  14. Return
    Subset (S, T)
    And
    Subset (S, T)
  15. End
  16. -- @ Head metamethods
    For
    Sets
  17. -- Set + Table = Union
  18. Retriable. _ add = Union
  19. -- Set-table = set difference
  20. Retriable. _ sub = difference
  21. -- Set/table = Intersection
  22. Retriable. _ DIV = Intersection
  23. -- Set <= table = subset
  24. 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 :)

 

  1. -- @ Func intersection: Find the intersection of two sets
  2. -- @ Param S, T: Sets
  3. -- @ Returns
  4. -- @ Param R: set intersection of S
    And
    T
  5. Function intersection (S, T)
  6. Local r = new {}

  7. For
    E
    In
    Elements (s) do

  8. If
    Member (T, E) then
  9. Insert (R, E)
  10. End
  11. End

  12. Return
    R
  13. End
  14. -- @ Func Union: Find the union of two sets
  15. -- @ Param S, T: Sets
  16. -- @ Returns
  17. -- @ Param R: set union of S
    And
    T
  18. Function Union (S, T)
  19. Local r = new {}

  20. For
    E
    In
    Elements (s) do
  21. Insert (R, E)
  22. End

  23. For
    E
    In
    Elements (t) Do
  24. Insert (R, E)
  25. End

  26. Return
    R
  27. End
  28. -- @ Func subset: Find whether one set
    Is
    A subset of another
  29. -- @ Param S, T: Sets
  30. -- @ Returns
  31. -- @ Param R: True
    If
    S
    Is
    A subset of T, false otherwise
  32. Function subset (S, T)

  33. For
    E
    In
    Elements (s) do

  34. If
     
    Not
    Member (T, E) then

  35. Return
    False
  36. End
  37. End

  38. Return
    True
  39. End
  40. -- @ Func propersubset: Find whether one set
    Is
    A proper subset
  41. -- Another
  42. -- @ Param S, T: Sets
  43. -- @ Returns
  44. -- @ Param R: True
    If
    S
    Is
    A proper subset of T, false otherwise
  45. Function propersubset (S, T)

  46. Return
    Subset (S, T)
    And
     
    Not
    Subset (t, s)
  47. End
  48. -- @ Func equal: Find whether two sets are equal
  49. -- @ Param S, T: Sets
  50. -- @ Returns
  51. -- @ Param R: True
    If
    Sets are equal, false otherwise
  52. Function equal (S, T)



  53. Return
    Subset (S, T)
    And
    Subset (t, s)
  54. End
  55. -- @ Head metamethods
    For
    Sets
  56. -- Set + Table = Union
  57. Retriable. _ add = Union
  58. -- Set-table = set difference
  59. Retriable. _ sub = difference
  60. -- Set * Table = Intersection
  61. Retriable. _ Mul = Intersection
  62. -- Set/table = distributed Ric difference
  63. Retriable. _ DIV = effecric_difference
  64. -- Set <= table = subset
  65. Retriable. _ LE = subset
  66. -- Set <Table = proper subset
  67. 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 :)

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.