From 922fd32a01dd4060a9670a44971a14610e2ffd1a Mon Sep 17 00:00:00 2001 From: Sayantan Dasgupta Date: Sun, 8 Oct 2023 13:54:02 +0530 Subject: [PATCH 1/9] Made initial structure --- web/thesauruses/_meta/language_basics.json | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 web/thesauruses/_meta/language_basics.json diff --git a/web/thesauruses/_meta/language_basics.json b/web/thesauruses/_meta/language_basics.json new file mode 100644 index 000000000..09c15f191 --- /dev/null +++ b/web/thesauruses/_meta/language_basics.json @@ -0,0 +1,39 @@ +{ + "meta": { + "structure": "language_basics", + "structure_name": "Basics of A Programming Language" + }, + "categories": { + "Typing Systems": { + "statically_typed": "The programming language may be statically typed", + "dynamically_typed": "The programming language may be dynamically typed" + }, + "Paradigm Category": { + "procedural_language": "Language extensively uses procedures to explicitly detail how tasks are performed", + "functional_language": "Language extensively uses functions, emphasize immutability", + "object_oriented_language": "Language extensively uses the concept of objects, which encapsulate data and behaviour" + }, + "Level of Abstraction": { + "low_level_language": "Language provides minimal abstraction from the hardware architecture of the computer", + "high_level_language": "Language provides a more abstract and user-friendly interface for software development" + }, + "Execution Method": { + "compiled_language": "Language is translated into machine code or an intermediate form by a compiler before execution", + "interpreted_language": "Language is executed line by line by an interpreter at runtime withot a separate compilation step" + }, + "Application Domain": { + "general_purpose_language": "Language is designed to be versatile and applicable to a wide range of tasks and applications", + "domain_specific_language": "Language is designed to address specific application domains or industries" + }, + "Historical Perspective": { + "first_generation_language": "First generation of programming language providing minimal to no abstraction over computer hardware", + "second_generation_language": "Use mnemonic code and symbols to represent machine-level instructions, providing a more human-readable way to program", + "third_generation_language": "High level programming language designed for general purpose programming, providing a higher level of abstraction and greater ease of use", + "fourth_generation_language": "High level programming language designed for specific applications or domains, often using natural language-like syntax and focusing on rapid application development" + }, + "Memory Management": { + "manual_management": "Languages where memory has to be managed by the programmer manually", + "automatic_management": "Languages with an extensive support of automatic memory management" + } + } +} \ No newline at end of file From 57cccace13c119f732942d3f21bc5f80a0122119 Mon Sep 17 00:00:00 2001 From: Sayantan Dasgupta Date: Thu, 12 Oct 2023 09:04:56 +0530 Subject: [PATCH 2/9] Made a basic structure for language basics --- web/thesauruses/_meta/language_basics.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/web/thesauruses/_meta/language_basics.json b/web/thesauruses/_meta/language_basics.json index 09c15f191..8f07f2c08 100644 --- a/web/thesauruses/_meta/language_basics.json +++ b/web/thesauruses/_meta/language_basics.json @@ -25,12 +25,6 @@ "general_purpose_language": "Language is designed to be versatile and applicable to a wide range of tasks and applications", "domain_specific_language": "Language is designed to address specific application domains or industries" }, - "Historical Perspective": { - "first_generation_language": "First generation of programming language providing minimal to no abstraction over computer hardware", - "second_generation_language": "Use mnemonic code and symbols to represent machine-level instructions, providing a more human-readable way to program", - "third_generation_language": "High level programming language designed for general purpose programming, providing a higher level of abstraction and greater ease of use", - "fourth_generation_language": "High level programming language designed for specific applications or domains, often using natural language-like syntax and focusing on rapid application development" - }, "Memory Management": { "manual_management": "Languages where memory has to be managed by the programmer manually", "automatic_management": "Languages with an extensive support of automatic memory management" From 877686086d997f0410e297f791f8be92dde597ac Mon Sep 17 00:00:00 2001 From: Sayantan Dasgupta Date: Thu, 12 Oct 2023 20:31:24 +0530 Subject: [PATCH 3/9] Resolved meta_info issue, and added another feature for language basics --- web/thesauruses/_meta/language_basics.json | 6 ++++++ web/thesauruses/meta_info.json | 1 + 2 files changed, 7 insertions(+) diff --git a/web/thesauruses/_meta/language_basics.json b/web/thesauruses/_meta/language_basics.json index 8f07f2c08..8410bb735 100644 --- a/web/thesauruses/_meta/language_basics.json +++ b/web/thesauruses/_meta/language_basics.json @@ -28,6 +28,12 @@ "Memory Management": { "manual_management": "Languages where memory has to be managed by the programmer manually", "automatic_management": "Languages with an extensive support of automatic memory management" + }, + "Generation": { + "first_generation": "Language consists of binary code directly understood and executed by a computer's central processing unit (CPU) and represent the lowest level of programming abstraction", + "second_generation": "Language uses mnemonic codes and symbols to represent machine-level instructions, providing a more human-readable way to program and interact with a computer's hardware.", + "third_generation": "High-level programming languages designed for general-purpose software development, offering a higher level of abstraction and greater ease of use compared to low-level languages like assembly.", + "fourth_generation": "High-level programming languages designed for specific applications or domains, often using natural language-like syntax and focusing on rapid application development." } } } \ No newline at end of file diff --git a/web/thesauruses/meta_info.json b/web/thesauruses/meta_info.json index d04d4cd99..cc41fb3a2 100644 --- a/web/thesauruses/meta_info.json +++ b/web/thesauruses/meta_info.json @@ -31,6 +31,7 @@ "exception_handling": "Exception Handling", "functions": "Functions, Methods, and Subroutines", "io": "Input and Output", + "language_basics": "Basics of A Programming Language", "lists": "Lists, Arrays, and Hashed Lists", "operators": "Logical and Mathematical/Arithmetic Operators", "queues_stacks": "Queues and Stacks", From f4f04b348683f120ea889610ebaed763ccac9a03 Mon Sep 17 00:00:00 2001 From: Sayantan Dasgupta Date: Wed, 18 Oct 2023 13:28:11 +0530 Subject: [PATCH 4/9] Added some more features to language basics --- web/thesauruses/_meta/language_basics.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/web/thesauruses/_meta/language_basics.json b/web/thesauruses/_meta/language_basics.json index 8410bb735..0de09acf0 100644 --- a/web/thesauruses/_meta/language_basics.json +++ b/web/thesauruses/_meta/language_basics.json @@ -34,6 +34,24 @@ "second_generation": "Language uses mnemonic codes and symbols to represent machine-level instructions, providing a more human-readable way to program and interact with a computer's hardware.", "third_generation": "High-level programming languages designed for general-purpose software development, offering a higher level of abstraction and greater ease of use compared to low-level languages like assembly.", "fourth_generation": "High-level programming languages designed for specific applications or domains, often using natural language-like syntax and focusing on rapid application development." + }, + "Entry Point": { + "main_function": "Entry point of the program is the main function of the file", + "custom_function": "In some programming languages, custom functions can be made to be the entry point of a program", + "script_file": "Entry point of the program is the top of the script file" + }, + "Comments": { + "single_line": "Single line comments are used for brief explanations. Most common indicators of single line comments are // and #", + "multi_line": "Multi line comments span multiple lines. Used for longer explanations, or for commenting out code which you do not intend to execute. Usually multi line comments are enclosed within /* ... */, ''' ... ''' or \"\"\" ... \"\"\" ", + "documentation": "Some programming languages have specific comment syntax for generating documentation. For example, Javadoc comments can be generated using /** ", + "special": "Some programming languages have a special comment syntax for specific purposes" + }, + "Library and Framework support": { + "standard_libraries": "Programming Language is supported by an extensive network of standard libraries which are not required to be imported externally", + "extensive_frameworks": "Language has a strong network of external frameworks for supporting additional functionalities. Usually the external libraries are installed into the project using a package manager, and imported into the required file using the `import` keyword" + }, + "Minimal Program": { + "hello_world": "The most minimal program to understand all the basics is the Hello World program. Here you only need to print \"Hello World\" to the console/output of the programming language of your choice." } } } \ No newline at end of file From 5178fffe741f63c814b99cd343e66b89b2d63fe7 Mon Sep 17 00:00:00 2001 From: PentW0lf <31568025+PentW0lf@users.noreply.github.com> Date: Sat, 28 Oct 2023 16:49:51 +0530 Subject: [PATCH 5/9] Added data types in lua --- web/thesauruses/lua/5/data_types.json | 72 +++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 web/thesauruses/lua/5/data_types.json diff --git a/web/thesauruses/lua/5/data_types.json b/web/thesauruses/lua/5/data_types.json new file mode 100644 index 000000000..6c1ae86cc --- /dev/null +++ b/web/thesauruses/lua/5/data_types.json @@ -0,0 +1,72 @@ +{ + "meta": { + "language": "lua", + "language_name": "Lua", + "structure": "data_types", + "language_version": "5.1" + }, + "concepts": { + "boolean": { + "name": "Boolean", + "not-implemented": true, + "comment": "The type boolean has two values, false and true and both nil and false make a condition false." + }, + "signed_integer_16_bit": { + "name": "Signed 16-bit integer", + "not-implemented": true + }, + "signed_integer_32_bit": { + "name": "Signed 32-bit integer", + "not-implemented": true + }, + "signed_integer_64_bit": { + "name": "Signed 64-bit integer", + "not-implemented": true + }, + "signed_integer_as_object": { + "name": "Signed object-based Integer", + "not-implemented": true, + "comment":"Lua does not have a built-in concept of distinct signed, object-based integers with the full range of operations and methods that you might find in languages like C++ or Java." + + }, + "signed_float_16_bit": { + "name": "Signed 16-bit floating point", + "not-implemented": true + }, + "signed_float_32_bit": { + "name": "Signed 32-bit floating point", + "not-implemented": true + }, + "signed_float_64_bit": { + "name": "Signed 64-bit floating point", + "not-implemented": true + }, + "signed_float_as_object": { + "name": "Signed object-based floating point", + "not-implemented": true, + "comment":"Same as integer applies here too." + }, + "string_as_object": { + "name": "String as an object", + "not-implemented": true, + "comment":"In Lua, strings are typically treated as sequences of characters and do not have built-in support for being 'signed' or 'object-based' in the same way that numbers do not." + }, + "string_as_array": { + "name": "String as an array of characters", + "not-implemented": true + }, + "complex_as_object": { + "name": "Complex Number as an object", + "not-implemented": true, + "comment":"In Lua, you can work with complex numbers by implementing your own data structure using tables or userdata, and define the necessary operations and methods for working with them." + }, + "real_number_part": { + "name": "Complex number real part", + "not-implemented": true + }, + "imaginary_number_part": { + "name": "Complex number imaginary part", + "not-implemented": true + } + } +} \ No newline at end of file From 57a283335d7dad4d88c5a8a0517699075cc8fb40 Mon Sep 17 00:00:00 2001 From: PentW0lf <31568025+PentW0lf@users.noreply.github.com> Date: Sat, 28 Oct 2023 22:17:26 +0530 Subject: [PATCH 6/9] Update data_types.json --- web/thesauruses/lua/5/data_types.json | 130 +++++++++++++++++++++++++- 1 file changed, 125 insertions(+), 5 deletions(-) diff --git a/web/thesauruses/lua/5/data_types.json b/web/thesauruses/lua/5/data_types.json index 6c1ae86cc..b45e08a98 100644 --- a/web/thesauruses/lua/5/data_types.json +++ b/web/thesauruses/lua/5/data_types.json @@ -8,65 +8,185 @@ "concepts": { "boolean": { "name": "Boolean", + "code": [ + "" + ], "not-implemented": true, "comment": "The type boolean has two values, false and true and both nil and false make a condition false." }, + "signed_integer_8_bit": { + "name": "Signed 8-bit integer", + "code": [ + "" + ], + "not-implemented": true + }, + "unsigned_integer_8_bit": { + "name": "Unsigned 8-bit integer", + "code": [ + "" + ], + "not-implemented": true + }, "signed_integer_16_bit": { "name": "Signed 16-bit integer", + "code": [ + "" + ], + "not-implemented": true + }, + "unsigned_integer_16_bit": { + "name": "Unsigned 16-bit integer", + "code": [ + "" + ], "not-implemented": true }, "signed_integer_32_bit": { "name": "Signed 32-bit integer", + "code": [ + "" + ], + "not-implemented": true + }, + "unsigned_integer_32_bit": { + "name": "Unsigned 32-bit integer", + "code": [ + "" + ], "not-implemented": true }, "signed_integer_64_bit": { "name": "Signed 64-bit integer", + "code": [ + "" + ], + "not-implemented": true + }, + "unsigned_integer_64_bit": { + "name": "Unsigned 64-bit integer", + "code": [ + "" + ], "not-implemented": true }, "signed_integer_as_object": { "name": "Signed object-based Integer", + "code": [ + "" + ], "not-implemented": true, "comment":"Lua does not have a built-in concept of distinct signed, object-based integers with the full range of operations and methods that you might find in languages like C++ or Java." - + }, + "unsigned_integer_as_object": { + "name": "Unsigned object-based Integer", + "code": [ + "" + ], + "not-implemented": true }, "signed_float_16_bit": { "name": "Signed 16-bit floating point", + "code": [ + "" + ], + "not-implemented": true + }, + "unsigned_float_16_bit": { + "name": "Unsigned 16-bit floating point", + "code": [ + "" + ], "not-implemented": true }, "signed_float_32_bit": { "name": "Signed 32-bit floating point", + "code": [ + "" + ], + "not-implemented": true + }, + "unsigned_float_32_bit": { + "name": "Unsigned 32-bit floating point", + "code": [ + "" + ], "not-implemented": true }, "signed_float_64_bit": { "name": "Signed 64-bit floating point", + "code": [ + "" + ], + "not-implemented": true + }, + "unsigned_float_64_bit": { + "name": "Unsigned 64-bit floating point", + "code": [ + "" + ], "not-implemented": true }, "signed_float_as_object": { "name": "Signed object-based floating point", + "code": [ + "" + ], "not-implemented": true, "comment":"Same as integer applies here too." }, + "unsigned_float_as_object": { + "name": "Unsigned object-based floating point", + "code": [ + "" + ], + "not-implemented": true + }, + "character": { + "name": "Character", + "code": [ + "" + ], + "not-implemented": true + }, "string_as_object": { "name": "String as an object", + "code": [ + "" + ], "not-implemented": true, - "comment":"In Lua, strings are typically treated as sequences of characters and do not have built-in support for being 'signed' or 'object-based' in the same way that numbers do not." + "comment":"In Lua, strings are not treated as objects in the same way that some other programming languages, like Python or JavaScript" }, "string_as_array": { "name": "String as an array of characters", - "not-implemented": true + "code": + [ + "local myString = 'Hello, World!'\nlocal firstChar = myString:sub(1, 1) -- Access the first character\nlocal fifthChar = myString:sub(5, 5) -- Access the fifth character\nprint(firstChar) -- Output: 'H'\nprint(fifthChar) -- Output: 'o'" + ], + "comment":"In Lua, strings are treated as arrays of characters." }, "complex_as_object": { "name": "Complex Number as an object", + "code": [ + "" + ], "not-implemented": true, - "comment":"In Lua, you can work with complex numbers by implementing your own data structure using tables or userdata, and define the necessary operations and methods for working with them." + "comment":"Lua does not have built-in support for complex numbers as a distinct data type like some other languages, such as Python." + }, "real_number_part": { "name": "Complex number real part", + "code": [ + "" + ], "not-implemented": true }, "imaginary_number_part": { "name": "Complex number imaginary part", + "code": [ + "" + ], "not-implemented": true } } -} \ No newline at end of file +} From c69bb1c06160a4a44590ffac21e7b3d96eab804f Mon Sep 17 00:00:00 2001 From: PentW0lf <31568025+PentW0lf@users.noreply.github.com> Date: Sat, 28 Oct 2023 22:26:36 +0530 Subject: [PATCH 7/9] Update data_types.json --- web/thesauruses/lua/5/data_types.json | 72 --------------------------- 1 file changed, 72 deletions(-) diff --git a/web/thesauruses/lua/5/data_types.json b/web/thesauruses/lua/5/data_types.json index b45e08a98..6dc5a20be 100644 --- a/web/thesauruses/lua/5/data_types.json +++ b/web/thesauruses/lua/5/data_types.json @@ -8,152 +8,89 @@ "concepts": { "boolean": { "name": "Boolean", - "code": [ - "" - ], "not-implemented": true, "comment": "The type boolean has two values, false and true and both nil and false make a condition false." }, "signed_integer_8_bit": { "name": "Signed 8-bit integer", - "code": [ - "" - ], "not-implemented": true }, "unsigned_integer_8_bit": { "name": "Unsigned 8-bit integer", - "code": [ - "" - ], "not-implemented": true }, "signed_integer_16_bit": { "name": "Signed 16-bit integer", - "code": [ - "" - ], "not-implemented": true }, "unsigned_integer_16_bit": { "name": "Unsigned 16-bit integer", - "code": [ - "" - ], "not-implemented": true }, "signed_integer_32_bit": { "name": "Signed 32-bit integer", - "code": [ - "" - ], "not-implemented": true }, "unsigned_integer_32_bit": { "name": "Unsigned 32-bit integer", - "code": [ - "" - ], "not-implemented": true }, "signed_integer_64_bit": { "name": "Signed 64-bit integer", - "code": [ - "" - ], "not-implemented": true }, "unsigned_integer_64_bit": { "name": "Unsigned 64-bit integer", - "code": [ - "" - ], "not-implemented": true }, "signed_integer_as_object": { "name": "Signed object-based Integer", - "code": [ - "" - ], "not-implemented": true, "comment":"Lua does not have a built-in concept of distinct signed, object-based integers with the full range of operations and methods that you might find in languages like C++ or Java." }, "unsigned_integer_as_object": { "name": "Unsigned object-based Integer", - "code": [ - "" - ], "not-implemented": true }, "signed_float_16_bit": { "name": "Signed 16-bit floating point", - "code": [ - "" - ], "not-implemented": true }, "unsigned_float_16_bit": { "name": "Unsigned 16-bit floating point", - "code": [ - "" - ], "not-implemented": true }, "signed_float_32_bit": { "name": "Signed 32-bit floating point", - "code": [ - "" - ], "not-implemented": true }, "unsigned_float_32_bit": { "name": "Unsigned 32-bit floating point", - "code": [ - "" - ], "not-implemented": true }, "signed_float_64_bit": { "name": "Signed 64-bit floating point", - "code": [ - "" - ], "not-implemented": true }, "unsigned_float_64_bit": { "name": "Unsigned 64-bit floating point", - "code": [ - "" - ], "not-implemented": true }, "signed_float_as_object": { "name": "Signed object-based floating point", - "code": [ - "" - ], "not-implemented": true, "comment":"Same as integer applies here too." }, "unsigned_float_as_object": { "name": "Unsigned object-based floating point", - "code": [ - "" - ], "not-implemented": true }, "character": { "name": "Character", - "code": [ - "" - ], "not-implemented": true }, "string_as_object": { "name": "String as an object", - "code": [ - "" - ], "not-implemented": true, "comment":"In Lua, strings are not treated as objects in the same way that some other programming languages, like Python or JavaScript" }, @@ -167,25 +104,16 @@ }, "complex_as_object": { "name": "Complex Number as an object", - "code": [ - "" - ], "not-implemented": true, "comment":"Lua does not have built-in support for complex numbers as a distinct data type like some other languages, such as Python." }, "real_number_part": { "name": "Complex number real part", - "code": [ - "" - ], "not-implemented": true }, "imaginary_number_part": { "name": "Complex number imaginary part", - "code": [ - "" - ], "not-implemented": true } } From 224eb983d6527b2cb930eea27a75c59a87cb066c Mon Sep 17 00:00:00 2001 From: PentW0lf <31568025+PentW0lf@users.noreply.github.com> Date: Sun, 29 Oct 2023 17:10:47 +0530 Subject: [PATCH 8/9] Add files via upload --- web/thesauruses/lua/5/functions.json | 118 +++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 web/thesauruses/lua/5/functions.json diff --git a/web/thesauruses/lua/5/functions.json b/web/thesauruses/lua/5/functions.json new file mode 100644 index 000000000..5ae70a75b --- /dev/null +++ b/web/thesauruses/lua/5/functions.json @@ -0,0 +1,118 @@ +{ + "meta": { + "language": "lua", + "language_name": "Lua", + "structure": "functions", + "language_version": "5.1" + }, + "concepts": { + "void_function_no_parameters": { + "name": "Function that does not return a value and takes no parameters", + "code": [ + "function greet()\n\tprint(\"Hello, world!\")\nend\n\n-- Calling the function\ngreet()" + ] + }, + "void_function_with_parameters": { + "name": "Function that does not return a value and that takes 1 or more defined parameters", + "code": [ + "function addNumbers(a, b)\n\tlocal sum = a + b\n\treturn sum\nend\n\n-- Calling the function and storing the result in a variable\nlocal result = addNumbers(5, 3)\nprint(\"The sum is: \" .. result)" + ] + }, + "void_function_with_keyword_parameters": { + "name": "Function that does not return a value and that takes 0 or more defined keyword parameters", + "code": [ + "function myFunction(params)\n\tlocal param1 = params.param1 or \"default_value1\"\n\tlocal param2 = params.param2 or \"default_value2\"\n\tlocal param3 = params.param3 or \"default_value3\"\n\t-- Your code here, using param1, param2, param3\n\tprint(\"param1: \" .. param1)\n\tprint(\"param2: \" .. param2)\n\tprint(\"param3: \" .. param3)\nend\n\n-- Calling the function with keyword parameters\nmyFunction{\n\tparam1 = \"value1\",\n\tparam2 = \"value2\",\n}\nmyFunction{\n\tparam2 = \"value2\",\n\tparam3 = \"value3\",\n}\n\n-- OutPut:\nparam1: value1\nparam2: value2\nparam3: default_value3\nparam1: default_value1\nparam2: value2\nparam3: value3" + ], + "comment":"Lua doesn't have built-in support for named or keyword parameters like some other programming languages do, such as Python. However, you can emulate keyword parameters using a table (Lua's equivalent to dictionaries or maps) and passing named values within that table as above." + + }, + "void_function_variable_parameters": { + "name": "Function that does not return a value and function that takes an unknown number of parameters", + "code": [ + "function myFunction(...)\n\tlocal params = {...}\n\tfor i, v in ipairs(params) do\n\t\tprint(\"Parameter \" .. i .. \": \" .. v)\n\tend\nend\n\n-- Calling the function with different numbers of parameters\nmyFunction(1, 2, 3)\nmyFunction(\"apple\", \"banana\")\nmyFunction(\"cat\")\n\n--OutPut:\nParameter 1: 1\nParameter 2: 2\nParameter 3: 3\nParameter 1: apple\nParameter 2: banana\nParameter 1: cat" + ] + }, + "return_value_function_no_parameters": { + "name": "Function that returns a value and takes no parameters", + "code": [ + "function generateRandomNumber()\n\treturn math.random(1, 100)\nend\n\n-- Calling the function and storing the result in a variable\nlocal randomValue = generateRandomNumber()\nprint(\"Random number: \" .. randomValue)" + ] + }, + "return_value_function_with_parameters": { + "name": "Function that returns a value and takes 1 or more defined parameters", + "code": [ + "function addNumbers(a, b)\nlocal sum = a + b\nreturn sum\nend\n\n-- Calling the function and storing the result in a variable\nlocal result = addNumbers(5, 3)\nprint(\"The sum is: \" .. result)\n\n-- OutPut:\nThe sum is: 8" + ] + }, + "return_value_function_with_keyword_parameters": { + "name": "Function that returns a value and takes 0 or more defined keyword parameters", + "code": [ + "function myFunction(params)\n\t-- Access parameters using named fields\n\tlocal param1 = params.param1 or \"default_value1\"\n\tlocal param2 = params.param2 or \"default_value2\"\n\tlocal param3 = params.param3 or \"default_value3\"\n\n\t-- Perform some operations\n\tlocal result = param1 .. \", \" .. param2 .. \", \" .. param3\n\n\t-- Return the result\n\treturn result\nend\n\n-- Calling the function with a table containing named parameters\nlocal output1 = myFunction{\n\tparam1 = \"value1\",\n\tparam2 = \"value2\",}\n\nlocal output2 = myFunction{\n\tparam2 = \"value2\",\n\tparam3 = \"value3\",}\n\nprint(\"Output 1: \" .. output1)\nprint(\"Output 2: \" .. output2)\n\n--OutPut:\nOutput 1: value1, value2, default_value3\nOutput 2: default_value1, value2, value3" + ], + "comment":"In Lua, you can't use keyword parameters as you would in some other programming languages like Python. However, you can achieve a similar effect by passing a table with named fields as a single parameter to the function as above." + }, + "return_value_function_variable_parameters": { + "name": "Function that returns a value and takes an unknown number of parameters", + "code": [ + "function sum(...)\n\tlocal result = 0\n\n\tfor i, v in ipairs({...}) do\n\t\tresult = result + v\n\tend\n\n\treturn result\nend\n\n-- Calling the function with different numbers of parameters\nlocal result1 = sum(1, 2, 3)\nlocal result2 = sum(5, 10, 15, 20)\n\nprint(\"Result 1: \" .. result1)\nprint(\"Result 2: \" .. result2)\n\n--OutPut\nResult 1: 6\nResult 2: 50" + ] + }, + "anonymous_function_no_parameters": { + "name": "Anonymous function that takes no parameters", + "code": [ + "local myFunction = function()\n\tprint(\"Anonymous function with no parameters\")\nend\n\nmyFunction()\n--OutPut\n\nAnonymous function with no parameters" + ] + }, + "anonymous_function_with_parameters": { + "name": "Anonymous function that takes 1 or more defined parameters", + "code": [ + "local add = function(a, b)\n\treturn a + b\nend\n\nlocal result = add(5, 3)\nprint(\"The sum is: \" .. result)\n--OutPut:\nThe sum is: 8" + ] + }, + "anonymous_function_with_keyword_parameters": { + "name": "Anonymous function that takes 0 or more defined keyword parameters", + "code": [ + "local myFunction = function(params)\n\tlocal param1 = params.param1 or 'default_value1'\n\tlocal param2 = params.param2 or 'default_value2'\n\tlocal param3 = params.param3 or 'default_value3'\n\n\t-- Your code here, using param1, param2, param3\n\tprint('param1: ' .. param1)\n\tprint('param2: ' .. param2)\n\tprint('param3: ' .. param3)\nend\n\n-- Call the anonymous function with keyword parameters\nmyFunction{\n\tparam1 = 'value1',\n\tparam2 = 'value2',\n}\n\nmyFunction{\n\tparam2 = 'value2',\n\tparam3 = 'value3',\n}\n--OutPut\n\nparam1: value1\nparam2: value2\nparam3: default_value3\nparam1: default_value1\nparam2: value2\nparam3: value3" + ] + }, + "anonymous_function_variable_parameters": { + "name": "Anonymous function that takes an unknown number of parameters", + "code": [ + "local myFunction = function(params)\n\tlocal param1 = params.param1 or 'default_value1'\n\tlocal param2 = params.param2 or 'default_value2'\n\tlocal param3 = params.param3 or 'default_value3'\n\n\t-- Your code here, using param1, param2, param3\n\tprint('param1: ' .. param1)\n\tprint('param2: ' .. param2)\n\tprint('param3: ' .. param3)\nend\n\n-- Call the anonymous function with keyword parameters\nmyFunction{\n\tparam1 = 'value1',\n\tparam2 = 'value2',\n}\n\nmyFunction{\n\tparam2 = 'value2',\n\tparam3 = 'value3',\n}\n\n--OutPut:\nparam1: value1\nparam2: value2\nparam3: default_value3\nparam1: default_value1\nparam2: value2\nparam3: value3" + ], + "comment":"In Lua, anonymous functions (also known as closures or lambdas) typically do not natively support keyword parameters as in some other programming languages. However, you can achieve a similar effect by passing a table with named fields as a single argument to the anonymous function as above." + }, + "anonymous_function_no_parameters_with_return": { + "name": "Anonymous function that takes no parameters and returns a value", + "code": [ + "local myFunction = function()\n\treturn 'Hello from the anonymous function!'\nend\n\n-- Call the anonymous function and capture the result\nlocal result = myFunction()\n\n-- Print the result\nprint(result)\n\nOutPut:\nHello from the anonymous function!" + ] + }, + "anonymous_function_with_parameters_with_return": { + "name": "Anonymous function that takes 1 or more defined parameters and returns a value", + "code": [ + "local add = function(a, b)\n\treturn a + b\nend\n\n-- Call the anonymous function with parameters and capture the result\nlocal result = add(5, 3)\n\n-- Print the result\nprint('The sum is: ' .. result)\n\n--OutPut:\nThe sum is: 8" + ] + }, + "anonymous_function_with_keyword_parameters_with_return": { + "name": "Anonymous function that takes 0 or more defined keyword parameters and returns a value", + "code": [ + "local myFunction = function(params)\n\tlocal param1 = params.param1 or 'default_value1'\n\tlocal param2 = params.param2 or 'default_value2'\n\tlocal param3 = params.param3 or 'default_value3'\n\n\t-- Your code here, using param1, param2, param3\n\tlocal result = param1 .. ', ' .. param2 .. ', ' .. param3\n\n\t-- Return the result\n\treturn result\nend\n\n-- Call the anonymous function with keyword parameters and capture the result\nlocal output1 = myFunction{\n\tparam1 = 'value1',\n\tparam2 = 'value2',\n}\n\nlocal output2 = myFunction{\n\tparam2 = 'value2',\n\tparam3 = 'value3',\n}\n\n-- Print the results\nprint('Output 1: ' .. output1)\nprint('Output 2: ' .. output2)\n\n--OutPut:\nOutput 1: value1, value2, default_value3\nOutput 2: default_value1, value2, value3" + ] + }, + "anonymous_function_variable_parameters_with_return": { + "name": "Anonymous function that takes an unknown number of parameters and returns a value", + "code": [ + "local myFunction = function(...)\n\tlocal params = {...}\n\tlocal result = 'Parameters: '\n\n\tfor i, v in ipairs(params) do\n\t\tresult = result .. 'Parameter ' .. i .. ': ' .. v .. ' '\n\tend\n\n\treturn result\nend\n\n-- Call the anonymous function with different numbers of parameters and capture the result\nlocal result1 = myFunction(1, 2, 3)\nlocal result2 = myFunction('apple', 'banana')\nlocal result3 = myFunction('cat')\n\n-- Print the results\nprint(result1)\nprint(result2)\nprint(result3)\n\n--OutPut:\nParameters: Parameter 1: 1 Parameter 2: 2 Parameter 3: 3 \nParameters: Parameter 1: apple Parameter 2: banana \nParameters: Parameter 1: cat" + ] + }, + "call_subroutine": { + "name": "Call subroutine", + "not-implemented": "true" + }, + "return_from_subroutine": { + "name": "Return from subroutine", + "not-implemented": "true" + } + } +} \ No newline at end of file From 83bc19add814ac1801b553aa421551429792e5e3 Mon Sep 17 00:00:00 2001 From: PentW0lf <31568025+PentW0lf@users.noreply.github.com> Date: Sun, 29 Oct 2023 17:13:45 +0530 Subject: [PATCH 9/9] Delete web/thesauruses/lua/5/functions.json --- web/thesauruses/lua/5/functions.json | 118 --------------------------- 1 file changed, 118 deletions(-) delete mode 100644 web/thesauruses/lua/5/functions.json diff --git a/web/thesauruses/lua/5/functions.json b/web/thesauruses/lua/5/functions.json deleted file mode 100644 index 5ae70a75b..000000000 --- a/web/thesauruses/lua/5/functions.json +++ /dev/null @@ -1,118 +0,0 @@ -{ - "meta": { - "language": "lua", - "language_name": "Lua", - "structure": "functions", - "language_version": "5.1" - }, - "concepts": { - "void_function_no_parameters": { - "name": "Function that does not return a value and takes no parameters", - "code": [ - "function greet()\n\tprint(\"Hello, world!\")\nend\n\n-- Calling the function\ngreet()" - ] - }, - "void_function_with_parameters": { - "name": "Function that does not return a value and that takes 1 or more defined parameters", - "code": [ - "function addNumbers(a, b)\n\tlocal sum = a + b\n\treturn sum\nend\n\n-- Calling the function and storing the result in a variable\nlocal result = addNumbers(5, 3)\nprint(\"The sum is: \" .. result)" - ] - }, - "void_function_with_keyword_parameters": { - "name": "Function that does not return a value and that takes 0 or more defined keyword parameters", - "code": [ - "function myFunction(params)\n\tlocal param1 = params.param1 or \"default_value1\"\n\tlocal param2 = params.param2 or \"default_value2\"\n\tlocal param3 = params.param3 or \"default_value3\"\n\t-- Your code here, using param1, param2, param3\n\tprint(\"param1: \" .. param1)\n\tprint(\"param2: \" .. param2)\n\tprint(\"param3: \" .. param3)\nend\n\n-- Calling the function with keyword parameters\nmyFunction{\n\tparam1 = \"value1\",\n\tparam2 = \"value2\",\n}\nmyFunction{\n\tparam2 = \"value2\",\n\tparam3 = \"value3\",\n}\n\n-- OutPut:\nparam1: value1\nparam2: value2\nparam3: default_value3\nparam1: default_value1\nparam2: value2\nparam3: value3" - ], - "comment":"Lua doesn't have built-in support for named or keyword parameters like some other programming languages do, such as Python. However, you can emulate keyword parameters using a table (Lua's equivalent to dictionaries or maps) and passing named values within that table as above." - - }, - "void_function_variable_parameters": { - "name": "Function that does not return a value and function that takes an unknown number of parameters", - "code": [ - "function myFunction(...)\n\tlocal params = {...}\n\tfor i, v in ipairs(params) do\n\t\tprint(\"Parameter \" .. i .. \": \" .. v)\n\tend\nend\n\n-- Calling the function with different numbers of parameters\nmyFunction(1, 2, 3)\nmyFunction(\"apple\", \"banana\")\nmyFunction(\"cat\")\n\n--OutPut:\nParameter 1: 1\nParameter 2: 2\nParameter 3: 3\nParameter 1: apple\nParameter 2: banana\nParameter 1: cat" - ] - }, - "return_value_function_no_parameters": { - "name": "Function that returns a value and takes no parameters", - "code": [ - "function generateRandomNumber()\n\treturn math.random(1, 100)\nend\n\n-- Calling the function and storing the result in a variable\nlocal randomValue = generateRandomNumber()\nprint(\"Random number: \" .. randomValue)" - ] - }, - "return_value_function_with_parameters": { - "name": "Function that returns a value and takes 1 or more defined parameters", - "code": [ - "function addNumbers(a, b)\nlocal sum = a + b\nreturn sum\nend\n\n-- Calling the function and storing the result in a variable\nlocal result = addNumbers(5, 3)\nprint(\"The sum is: \" .. result)\n\n-- OutPut:\nThe sum is: 8" - ] - }, - "return_value_function_with_keyword_parameters": { - "name": "Function that returns a value and takes 0 or more defined keyword parameters", - "code": [ - "function myFunction(params)\n\t-- Access parameters using named fields\n\tlocal param1 = params.param1 or \"default_value1\"\n\tlocal param2 = params.param2 or \"default_value2\"\n\tlocal param3 = params.param3 or \"default_value3\"\n\n\t-- Perform some operations\n\tlocal result = param1 .. \", \" .. param2 .. \", \" .. param3\n\n\t-- Return the result\n\treturn result\nend\n\n-- Calling the function with a table containing named parameters\nlocal output1 = myFunction{\n\tparam1 = \"value1\",\n\tparam2 = \"value2\",}\n\nlocal output2 = myFunction{\n\tparam2 = \"value2\",\n\tparam3 = \"value3\",}\n\nprint(\"Output 1: \" .. output1)\nprint(\"Output 2: \" .. output2)\n\n--OutPut:\nOutput 1: value1, value2, default_value3\nOutput 2: default_value1, value2, value3" - ], - "comment":"In Lua, you can't use keyword parameters as you would in some other programming languages like Python. However, you can achieve a similar effect by passing a table with named fields as a single parameter to the function as above." - }, - "return_value_function_variable_parameters": { - "name": "Function that returns a value and takes an unknown number of parameters", - "code": [ - "function sum(...)\n\tlocal result = 0\n\n\tfor i, v in ipairs({...}) do\n\t\tresult = result + v\n\tend\n\n\treturn result\nend\n\n-- Calling the function with different numbers of parameters\nlocal result1 = sum(1, 2, 3)\nlocal result2 = sum(5, 10, 15, 20)\n\nprint(\"Result 1: \" .. result1)\nprint(\"Result 2: \" .. result2)\n\n--OutPut\nResult 1: 6\nResult 2: 50" - ] - }, - "anonymous_function_no_parameters": { - "name": "Anonymous function that takes no parameters", - "code": [ - "local myFunction = function()\n\tprint(\"Anonymous function with no parameters\")\nend\n\nmyFunction()\n--OutPut\n\nAnonymous function with no parameters" - ] - }, - "anonymous_function_with_parameters": { - "name": "Anonymous function that takes 1 or more defined parameters", - "code": [ - "local add = function(a, b)\n\treturn a + b\nend\n\nlocal result = add(5, 3)\nprint(\"The sum is: \" .. result)\n--OutPut:\nThe sum is: 8" - ] - }, - "anonymous_function_with_keyword_parameters": { - "name": "Anonymous function that takes 0 or more defined keyword parameters", - "code": [ - "local myFunction = function(params)\n\tlocal param1 = params.param1 or 'default_value1'\n\tlocal param2 = params.param2 or 'default_value2'\n\tlocal param3 = params.param3 or 'default_value3'\n\n\t-- Your code here, using param1, param2, param3\n\tprint('param1: ' .. param1)\n\tprint('param2: ' .. param2)\n\tprint('param3: ' .. param3)\nend\n\n-- Call the anonymous function with keyword parameters\nmyFunction{\n\tparam1 = 'value1',\n\tparam2 = 'value2',\n}\n\nmyFunction{\n\tparam2 = 'value2',\n\tparam3 = 'value3',\n}\n--OutPut\n\nparam1: value1\nparam2: value2\nparam3: default_value3\nparam1: default_value1\nparam2: value2\nparam3: value3" - ] - }, - "anonymous_function_variable_parameters": { - "name": "Anonymous function that takes an unknown number of parameters", - "code": [ - "local myFunction = function(params)\n\tlocal param1 = params.param1 or 'default_value1'\n\tlocal param2 = params.param2 or 'default_value2'\n\tlocal param3 = params.param3 or 'default_value3'\n\n\t-- Your code here, using param1, param2, param3\n\tprint('param1: ' .. param1)\n\tprint('param2: ' .. param2)\n\tprint('param3: ' .. param3)\nend\n\n-- Call the anonymous function with keyword parameters\nmyFunction{\n\tparam1 = 'value1',\n\tparam2 = 'value2',\n}\n\nmyFunction{\n\tparam2 = 'value2',\n\tparam3 = 'value3',\n}\n\n--OutPut:\nparam1: value1\nparam2: value2\nparam3: default_value3\nparam1: default_value1\nparam2: value2\nparam3: value3" - ], - "comment":"In Lua, anonymous functions (also known as closures or lambdas) typically do not natively support keyword parameters as in some other programming languages. However, you can achieve a similar effect by passing a table with named fields as a single argument to the anonymous function as above." - }, - "anonymous_function_no_parameters_with_return": { - "name": "Anonymous function that takes no parameters and returns a value", - "code": [ - "local myFunction = function()\n\treturn 'Hello from the anonymous function!'\nend\n\n-- Call the anonymous function and capture the result\nlocal result = myFunction()\n\n-- Print the result\nprint(result)\n\nOutPut:\nHello from the anonymous function!" - ] - }, - "anonymous_function_with_parameters_with_return": { - "name": "Anonymous function that takes 1 or more defined parameters and returns a value", - "code": [ - "local add = function(a, b)\n\treturn a + b\nend\n\n-- Call the anonymous function with parameters and capture the result\nlocal result = add(5, 3)\n\n-- Print the result\nprint('The sum is: ' .. result)\n\n--OutPut:\nThe sum is: 8" - ] - }, - "anonymous_function_with_keyword_parameters_with_return": { - "name": "Anonymous function that takes 0 or more defined keyword parameters and returns a value", - "code": [ - "local myFunction = function(params)\n\tlocal param1 = params.param1 or 'default_value1'\n\tlocal param2 = params.param2 or 'default_value2'\n\tlocal param3 = params.param3 or 'default_value3'\n\n\t-- Your code here, using param1, param2, param3\n\tlocal result = param1 .. ', ' .. param2 .. ', ' .. param3\n\n\t-- Return the result\n\treturn result\nend\n\n-- Call the anonymous function with keyword parameters and capture the result\nlocal output1 = myFunction{\n\tparam1 = 'value1',\n\tparam2 = 'value2',\n}\n\nlocal output2 = myFunction{\n\tparam2 = 'value2',\n\tparam3 = 'value3',\n}\n\n-- Print the results\nprint('Output 1: ' .. output1)\nprint('Output 2: ' .. output2)\n\n--OutPut:\nOutput 1: value1, value2, default_value3\nOutput 2: default_value1, value2, value3" - ] - }, - "anonymous_function_variable_parameters_with_return": { - "name": "Anonymous function that takes an unknown number of parameters and returns a value", - "code": [ - "local myFunction = function(...)\n\tlocal params = {...}\n\tlocal result = 'Parameters: '\n\n\tfor i, v in ipairs(params) do\n\t\tresult = result .. 'Parameter ' .. i .. ': ' .. v .. ' '\n\tend\n\n\treturn result\nend\n\n-- Call the anonymous function with different numbers of parameters and capture the result\nlocal result1 = myFunction(1, 2, 3)\nlocal result2 = myFunction('apple', 'banana')\nlocal result3 = myFunction('cat')\n\n-- Print the results\nprint(result1)\nprint(result2)\nprint(result3)\n\n--OutPut:\nParameters: Parameter 1: 1 Parameter 2: 2 Parameter 3: 3 \nParameters: Parameter 1: apple Parameter 2: banana \nParameters: Parameter 1: cat" - ] - }, - "call_subroutine": { - "name": "Call subroutine", - "not-implemented": "true" - }, - "return_from_subroutine": { - "name": "Return from subroutine", - "not-implemented": "true" - } - } -} \ No newline at end of file