codethesaurus / codethesaur.us

A polyglot developer reference tool to compare programming language concepts side-by-side! Great for learning new languages or using for reference.
https://codethesaur.us
GNU Affero General Public License v3.0
288 stars 166 forks source link

Clarify operand placement in language definitions of math operators #512

Open geekygirlsarah opened 2 years ago

geekygirlsarah commented 2 years ago

Language

Likely all of them

Wrong Field(s)

Most languages usually use something along the lines of the operator in between two operands (i.e. a + b). Not all languages do, notably something like LISP does (+ a b).

There are also prefix and postfix operators that might get confusing if people don't understand what prefix and postfix are. (As in what's the difference between ++ and ++ when we really mean ++a and a++?)

This would be to go through the languages and add in operators to them. Likely most of them are standard infix ones (a + b) except prefix/postfix above. For languages that differ, I can help catch it in PR.

This probably means doing something like: "addition_operator": "operand1 + operand2" (or something else like a + b to make it understandable and thorough).

Additional notes

Check out the documentation at https://docs.codethesaur.us if you need additional help or ask any questions you might have.

Neeraj8949 commented 2 years ago

I can work on it . Please assign to me.

geekygirlsarah commented 2 years ago

Great, I'll add you!

If you have any questions, let me know. And feel free to read the documentation if you need any help!

Neeraj8949 commented 2 years ago

include

using namespace std void Addition(int a, int b){ //if user want to add two number , he only needs to call the function "Addition" cout<< a+b<<endl; } // that easier to use for everyone . These type of function made easy to use int main() { string s; cin>>s; //which type of mathematic operator you want return 0;} Tell me , is this correct or You want something else .

geekygirlsarah commented 2 years ago

Oh no, you're overthinking it!

For example, take https://github.com/codethesaurus/codethesaur.us/blob/117b77a54b8b203ac99a2a74d61d006fe8ca02d7/web/thesauruses/cpp/C%2B%2B20/operators.json#L9L12 :

Change: "code": "+", to "code": "operand1 + operand2",

That's all. Make it obvious the order of the operators relative to the operands. Don't add any extra code (like functions, includes, etc.) unless for some reason you need it (like Java needs an import to do exponents). Definitely don't write a full program for it!

This is just to clarify something like C++ (a + b) vs LISP ((+ a b)) or other languages where order may not be obvious. Same for like C++'s prefix increment (++a) vs C++'s postfix increment (a++).

Does this help explain a little better?

Neeraj8949 commented 2 years ago

"concepts": { "addition": { "code": "+", "name": "Addition operator" "code": "operand1 + operand2" }, just like this only? will I do for all operator?

Neeraj8949 commented 2 years ago

If I am thinking in right way then tell me I will give you the all solution tomorrow.

geekygirlsarah commented 2 years ago

So you won't change anything in the file BUT the code lines. If you change the rest of the file, it won't work right.

You'll only be adding operands to the code lines. Don't add extra lines, just change/edit them.

And yes, the issue is to do it for all operators in all files in /web/thesauruses/[language].

If this is too much for a first-time contributor, I understand and you can take another issue or back out of this one if you want!

Neeraj8949 commented 2 years ago

Operand1=a; Operand2=b; "code": "+" "code": "a+b" //Sum is Operand1 + Operand2

geekygirlsarah commented 2 years ago

Do either: "code": "operand1 + operand2" or "code": "a + b"

Not both, and don't try adding extra things into it. You are just adding operands into the existing code lines.

Neeraj8949 commented 2 years ago

"code": "+" "code": "a+b" //Sum of two number So this is correct?

geekygirlsarah commented 2 years ago

Hmm... I'm not sure how to really clear this up any more than I've already tried.

Can you go ahead and make a few changes you think are right, then make a pull request. We can then look at them in there and hopefully clear it up. Then you can do the changes everywhere.

Does that sound good?

geekygirlsarah commented 2 years ago

Here, I also made an example:

image

The left side are the original lines (with changes in red). The right side is the modified side (with changes in green). This issue is to only modify the code lines to add in operand variables.

Neeraj8949 commented 2 years ago
  1. "meta":`` {
  2. "language": "cpp",
  3. "language_version": "C++20",
  4. "language_name": "C++",
  5. "structure": "operators"
  6. },
  7. "concepts": {
  8. "addition": {
  9. "code": "operand1 + operand2",
  10. "name": "Addition operator"
  11. },
  12. "addition_assignment": {
  13. "code": "result+=operand1",
  14. "name": "Addition and assignment operator"
  15. },
  16. "subtraction": {
  17. "code": "operand1 - operand2",
  18. "name": "Subtraction operator"
  19. },
  20. "subtraction_assignment": {
  21. "code": "result -= operand1",
  22. "name": "Subtraction and assignment operator"
  23. },
  24. "multiplication": {
  25. "code": "operand1 * operand2",
  26. "name": "Multiplication operator"
  27. },
  28. "multiplication_assignment": {
  29. "code": "result *= operand1",
  30. "name": "Multiplication and assignment operator"
  31. },
  32. "division": {
  33. "code": "operand1 / operand2",
  34. "name": "Division operator"
  35. },
  36. "division_assignment": {
  37. "code": "result /= operand1",
  38. "name": "Division and assignment operator"
  39. },
  40. "modulus": {
  41. "code": "operand1 % operand2",
  42. "name": "Modulus (remainder) operator"
  43. },
  44. "modulus_assignment": {
  45. "code": "result %= operand",
  46. "name": "Modulus and assignment operator"
  47. },
  48. "increment": {
  49. "comment": "There are two types of increment: pre-increment (++x) and post-increment (x++). ",
  50. "code": "operand1++ or operand1 = operand1+1",
  51. "name": "Increment (add 1) operator"
  52. },
  53. "decrement": {
  54. "comment": "There are two types of decrement: pre-decrement (--x) and post-decrement (x--). ",
  55. "code": "operand1-- or operand1 = operand1 - 1",
  56. "name": "Decrement (subtract 1) operator"
  57. },
  58. "equal_to": {
  59. "code": "==",
  60. "name": "Equality operator"
  61. },
  62. "not_equal_to": {
  63. "code": "!=",
  64. "name": "Not equal to operator"
  65. },
  66. "less_than": {
  67. "code": "operand1< operand2",// operand1 is less than operand2
  68. "name": "Less than operator"
  69. },
  70. "less_than_or_equal_to": {
  71. "code": "operand1 <= operand2 ",//operand1 is less than or equal to operand2
  72. "name": "Less than or equal to operator"
  73. },
  74. "greater_than": {
  75. "code": "operand1 > operand2", //operand1 is greater than operand2
  76. "name": "Greater than operator"
  77. },
  78. "greater_than_or_equal_to": {
  79. "code": "operand1 >= operand2 ",//operand1 is less than or equal to operand2
  80. "name": "Greater than or equal to operator"
  81. }

.. sorry to late . so is this correct or I have do more modification in this

geekygirlsarah commented 2 years ago

Yeah, basically! Go ahead and make a pull request with that and I can point more specifically to a couple of things.

Neeraj8949 commented 2 years ago

I didn't get it yet and tell me also that upper comment error and what type of changes and what type of new things which I have to add

geekygirlsarah commented 2 years ago

I'm not sure if I understand what you mean by "I didn't get it yet" and the upper comment error.

If this issue is too confusing, you're welcome to back out, or to pick a different issue to work on.

Neeraj8949 commented 2 years ago

I am new user on github so please tell me , now what I have to do

geekygirlsarah commented 2 years ago

Are you familiar with git and how to commit code? If not, you might want to find a tutorial, video, or something on how to do that.

The next step is to make a pull request. You can read directions about that on GitHub's documentation site.

At that point, you will have saved your code, stored it on GitHub, then made a pull request, which will compare your changes to what exists in Code Thesaurus now. I can then look at those changes and make suggestions, and we can validate that they work and the project builds.

Rishav-12 commented 2 years ago

Hey can I work on implementing this in the Python and JavaScript folders?

geekygirlsarah commented 2 years ago

Hey @Rishav-12, I think that would be good to help divide up the work! I'll assign you too.

There's examples of what I'm looking for with this issue above. There's also the documentation site too. If you have other questions, let me know!

Rishav-12 commented 2 years ago

Hey @geekygirlsarah, I just pushed some changes to the Python folder. I shall continue working on the JavaScript folder and push further changes

geekygirlsarah commented 2 years ago

That works! You can mark it as a "draft" pull request if you're not done but it can keep it there if you want.

image

geekygirlsarah commented 2 years ago

@Neeraj8949 If you look at pull request #556, you'll see how @Rishav-12 made the changes. Do you think you can do that for other languages?

@Rishav-12 do you want to take on any other languages?

Both of you: I can also split this out into separate issues for all the languages if you want to have a smaller issue.

github-actions[bot] commented 2 years ago

This issue has been inactive for 356 hours (14.83 days) and will be unassigned after 52 more hours (2.17 days). If you have questions, please visit leave a message or let @geekygirlsarah know by Twitter or email.

If you are still working on this issue, that's fine. Please comment here to tell the bot to give you more time.

github-actions[bot] commented 2 years ago

This issue has been inactive for 428 hours (17.83 days) and is past the limit of 408 hours (17.00 days) so is being unassigned.You’ve just been unassigned from this ticket due to inactivity – but feel free to pick it back up (or a new one!) in the future! Thank you again for your contribution to this project.