Wikifunctions:Status updates/2024-03-07

From Wikifunctions
Wikifunctions Status updates Translate

<translate> Abstract Wikipedia via mailing list</translate> <translate> Abstract Wikipedia on IRC</translate> <translate> Wikifunctions on Telegram</translate> <translate> Wikifunctions on Mastodon</translate> <translate> Wikifunctions on Twitter</translate> <translate> Wikifunctions on Facebook</translate> <translate> Wikifunctions on YouTube</translate> <translate> Wikifunctions website</translate> Translate

Introducing our second new type: Natural numbers

When Wikifunctions was made publicly available last year, we supported only two types: Strings and Booleans. In January, we introduced Lists.

We are happy to announce that the second new type is now available for use by the community: the long-awaited Natural numbers.

What is a natural number? A natural number is what you would usually use to count things. For Wikifunctions, we define this as whole numbers starting with zero and continuing with one, two, three, and so on. No upper limit is defined (but please don’t try to smash the servers trying to find it). We presented a proposal last week, and had some adjustments based on the community discussion.

What are natural numbers good for? Mainly for two things: for counting, and for arithmetics. Given the previously introduced lists, a very natural question is to ask for the length of a list (the same also for the length of a string). Natural numbers are made for that.

We do not yet support proper internationalization with types like natural numbers. We are currently working on renderers and parsers, and will report here when they are available. We also do not support typed lists of natural numbers yet.

We were very excited when the necessary technical features for natural numbers were deployed, which we discussed previously, and have now renamed type converters. We then created the natural number type and the necessary type converters just before Monday’s Volunteer’s Corner, and then went ahead without testing, due to time constraints, into the Volunteer’s Corner to create the first function. We first aimed for addition, but then we realized that in order to write the tests, we first needed equality. We started creating both, but the tests for equality failed.

In the recording for the Volunteers’ Corner, available on Commons, you can watch us try to debug together live what is going on, but we had to stop before achieving our goal. The next day, we fixed the configuration issue, and so on Tuesday the type went live. Since then, more than eighty new functions using natural numbers have been created!

We are excited about the new type, and are looking forward to seeing how the community will use it!

Recent changes in the software

Alongside our visible work to enable Natural number as the first user-controlled Type, discussed above, which included enabling type converters on the back-end services, we've made some more progress on the front-end user experience of custom Types, which will be coming soon.

As well as the priority work, this week we have also fixed a pair of user experience tweaks. We've simplified the header on each Object page to drop the type from the main heading as it's repeated in the sub-heading (T357807), and the warning message that you can't use a function because it has no implementations now won't show up before you've selected a function (T346852).

Wiki Mentor Africa: Presentation and tutorial of Wikifunctions

Over the weekend we gave a presentation and tutorial during the Wiki Mentor Africa program. More than 120 people attended the presentation on Saturday, and on Sunday Hogü gave a hands-on tutorial on how to translate labels on Wikifunctions into different languages. We thank Benedict for organizing the event, Hogü for the tutorial, and everyone for attending. Recordings will be available soon.

Function of the Week: is decimal natural number string of Arabic numerals (Z13489)

Last week we presented the proposal for natural numbers, which is now implemented. It included a proposal for the validator, and in preparation for the type and in response to the proposal, a function to check whether a string is a decimal natural number string of Arabic numerals was created.

This is used to check the value for how natural numbers are represented internally. It currently has three implementations:

Surprisingly, there is no implementation in JavaScript yet.

One particular strength of this function is that it has a quite comprehensive set of tests. We can find eleven tests connected with the function, checking that 1 and 1234567890 both are valid, but 0987654321 is not (due to the leading zero), and yet ensuring that 0 itself is valid and not mixed up with a leading zero. It further checks a number of strings that look like a number from one point of view or another: the English word "nine", "-1" (negative numbers are not allowed), the Arabic script number "١٥", Hexadecimal "FFFFFF", "99,999" (with the comma), and "1.00" (with the radix dot) are all tested as invalid. Finally, one test ensures that the empty string is also invalid.

This set of tests is exemplary, and it is great to see the various implementations. This week’s Function of the Week is in many ways a great example of a function on Wikifunctions.