User:Ajuanca/sandbox

Hi! This page is the official Ajuanca´s sandbox. To know more about what a sandbox is, visit this page.

TASK 1


imgs

TASK 2
Q1. What keyword marks the start of a function definition? A1. The keyword is function.

Q2. Which letter is conventionally used in Scribunto modules to hold the table of functions? A2. The common letter used is p.

Q3. What keyword marks the end of a function definition? A3. The keyword is end.

TASK 3

 * When the temperature is 9, the comparison considers it smaller. I added a specific answer for temperature equals 9:


 * When no value is given to celsius parameter, it considers that it isn't given:


 * When the wrong variable type is written, it considers that it isn't given:

Patterns and matching
Q1. What does %w+ match in a Lua pattern? A1. As it's written in the documentation, it represents all ASCII alphanumeric characters. In this case, they'll correspond to the month.

Q2. What does %d+ match in a Lua pattern? A2. As it's written in the documentation, it represents all digits. In this case, they'll correspond to the day or year.

Yes, I can figure out how does it works. The input is passed to the function and then saved to the variable dmy. After that, there're declared three variables that will come from casting dmy into three pieces, thanks to the method string.match that, as it's written in the documentation, it compares the first parameter, in this case, dmy, with a given parameter as a second attribute, in this case, numbers characters numbers, that are saved corresponding to the variables d, m and y. Finally, the variables are concatenated with some text and returned.

In order to get the values of the day, month and year in this format, we should modify the line that saves each value in the variable, searching in the first place instead of the day the month, in second place the day and lastly the year. Note that as also a comma is introduced, we also should cast it. I made a function p.unpackUS that applies this changes. I also implemented some lines to get the ordinal position of the month. In the above example, the given value was "mdydate=October 31, 2018"

Test 1
The input is

Test 2
The input is

Test 3
The input is

Test 4
The input is

Test 5
The input is

Test 6
The input is

Experimenting

 * When you give the character, the function is called and the Wikimedia syntax interprets it as a bulleted-list item.


 * When you give, a non-related Sandbox problem appears:

Lua error in mw.title.lua at line 206: bad argument #1 to 'pairs' (table expected, got nil).
 * When no attribute is given, the following error appears:

Lua error: bad argument #1 to 'title.new' (number or string expected, got nil).
 * When no value is given to the attribute :


 * When you request a page that existed but now is deleted:

Non-requested implementations
The input is
 * Now detects subpages and talk pages:

The input is

Organize all languages [in development]

 * Return list with ordered languages.

Fetching a date
In the below example, we can see how the data is returned from the Wikimedia database. A  precedes the date (obviously a time-data type). After it, the year, a, the month, another  , the day,  and without any separation, a   that indicates the start of the specific time in the form  , which null value is  , and finally, also without separation, a.


 * The input is  and.


 * The input is  and.


 * The input is  and.

Fetching a full date

 * The input is  and.


 * The input is  and.


 * The input is  and.

Fetching an item

 * The input is  and.


 * The input is  and.