Wikifunctions:Suggest a function - Wikifunctions
Jump to content
From Wikifunctions
Shortcuts
WF:SAF
WF:RF
Do you have an idea for a new function? Suggest it here! It may help to refer to
our glossary
You can
create a function
right away if you have the user-rights.
If a function requires a new type, consider
proposing it
Note that for now
we only support a limited number of types as input and output types
of functions. More types are coming in the next few months. For the full list, see
WF:Type
Once created, consider adding new Functions to the
catalogue
Requests from Abstract Wikipedia editors
Main page
abstract:Project:Suggested functions
Proposed functions requiring only available types
String
String character discard functions
String character replacement functions
Add the word 'the' to the start of a function. e.g United Kingdom - the United Kingdom.
FantasticWikiUser
talk
11:27, 25 March 2026 (UTC)
reply
Yes… simple enough to do but not entirely clear when it is required. We’ve been
discussing it on Telegram
GrounderUK
talk
12:10, 25 March 2026 (UTC)
reply
This was an issue I found on
abstract:Q21
when I couldn't add it there.
FantasticWikiUser
talk
12:16, 25 March 2026 (UTC)
reply
I worked on
definite article or empty string (en) (
Z33138
today. I'm not sure it covers all corner cases, feel free to try it out and add more tests
:)
So9q
talk
20:32, 5 April 2026 (UTC)
reply
String search functions
String escaping and unescaping functions
String encoding and decoding functions
Unicode normalising functions (there are several types of normalisation)
HTML named character encode
Punycode encode
Punycode encode (
Z10178
):
Description missing
(part only, not whole url); see also
IDNA encode (
Z10185
):
Description missing
Unified English Braille encode
(discarding invalid characters?)
Dutch eight-dot Braille
encode
JhowieNitnek
talk
21:38, 17 January 2026 (UTC)
reply
Dutch eight-dot Braille
decode
JhowieNitnek
talk
21:38, 17 January 2026 (UTC)
reply
Dutch six-dot Braille
encode
JhowieNitnek
talk
21:38, 17 January 2026 (UTC)
reply
Dutch six-dot Braille
decode
JhowieNitnek
talk
21:38, 17 January 2026 (UTC)
reply
IPA Braille
encode (IPA --> IPA Braille)
JhowieNitnek
talk
11:42, 18 January 2026 (UTC)
reply
IPA Braille
decode (IPA Braille --> IPA)
JhowieNitnek
talk
11:42, 18 January 2026 (UTC)
reply
String presentation functions
add
locale-specific quotation marks
to string
Shouldn't the output depend on the locale? See
mw.language:formatNum
. —
Dexxor
talk
17:15, 4 September 2023 (UTC)
reply
String colour notation functions
Hue of color (since we already have
Z13017
Z18263
and
Z18268
String notation validation checks
check if string is an
en:International_Chemical_Identifier
Partly done
see
Validate International Chemical Identifier (
Z21539
):
State whether a given International Chemical Identifier is valid or not.
. Supports the verification of the chemical formula and the stereochemical layer. There are 13 testcaes that I've written, all of which are passed by my JavaScript implementation. Note that a python implementation is not possible as the regex module is not available in Wikifunctions.
MolecularPilot
talk
03:09, 11 January 2025 (UTC)
reply
To do:
Needs to verify the hydrogen and connection sections of the main layer
Support the charge layer
Support the isotopic layer
MolecularPilot
talk
03:09, 11 January 2025 (UTC)
reply
MolecularPilot
A python impl. is infact possible. I created a basic direct translation at
International Chemical Identifier validation, py (
Z22823
):
Description missing
. Some tests are failing as the regex needs a bit of sorting out, out of scope for me, but you can give it a try! Keep in mind that you need to escape any \ with a \\ just before saving per
Wikifunctions:Python_implementations#Known_limitations_as_of_October_2024
~/Bunny
pranav
ping
06:14, 26 February 2025 (UTC)
reply
check if string is a
SMILES arbitrary target specification (SMARTS) notation
check if string is an
ABC notation
check if string is a
LilyPond notation
check if string is a
UIC classification of locomotive axle arrangements notation
check if a string is a valid
DOI
Something about implementation difficulties:
Alexander-Mart-Earth
talk
14:28, 21 December 2023 (UTC)
reply
String validation checks
check if string is a valid ISO 3166 country code
check if string is a valid
EDTF
date/time
String analysis functions
Monolingual text
String Wikitext operations
...
Natural number
Integer
Byte
See
existing Byte functions
in catalogue.
next byte without overflow: byte → byte
previous byte without overflow: byte → byte
next byte by Gray code: byte → byte
previous byte by Gray code: byte → byte
all bits set: byte → boolean
no bits set: byte → boolean
add bytes without overflow: byte, byte → byte
subtract bytes without overflow: byte, byte → byte
multiply bytes without overflow: byte, byte → byte
add bytes with overflow: byte, byte → byte
subtract bytes with overflow: byte, byte → byte
multiply bytes with overflow: byte, byte → byte
modulo bytes: byte, byte → byte
byte division: byte, byte → byte
right shift: byte → byte
left shift: byte → byte
right shift by n: byte, natural number → byte
left shift by n: byte, natural number → byte
right shift as ring: byte → byte
left shift as ring: byte → byte
right shift by n as ring: byte, natural number → byte
left shift by n as ring: byte, natural number → byte
Unicode code point
See
existing code point functions in catalogue
Codepoint to list of bytes for UTF-8
Codepoint to list of bytes for UTF-16
Codepoint to list of bytes for UTF-32
Object
List
Basic list/iterable functions
Complex list functions
CSV list operations
Functions with functions as arguments
test whether certain functions have specific properties of
homogeneous relations
for particular lists/sets
Gregorian calendar date
See
catalogue of calendar date functions
for existing functions.
Create a reading function for Dagbani that handles all the possible formats (both the English-linke and the traditional ones, both the Gregorian and the Hijra calendars).
Dv103
talk
15:43, 31 May 2025 (UTC)
reply
same day of the year: date, date → boolean
same day of the week: date, date → boolean
within a year: date, date → boolean
within a week: date, date → boolean
within n days: date, date → boolean
months between: date, date → natural number
weeks between: date, date → natural number
n days later: date, natural number → date
n days earlier: date, natural number → date
n weeks earlier: date, natural number → date
n months later: date, natural number → date
n months earlier: date, natural number → date
n years later: date, natural number → date
n years earlier: date, natural number → date
Julian day number to date: integer → date
how many leap days passed between two dates: date, date → natural number
how many weekdays between two dates: date, date, day of the week → natural number
within JavaScript's date implementation: date → boolean
next time a day of the month is on a specific weekday: date, natural number, day of the week → date
next Friday the 13th: date → date
nth weekday of the month: date, day of the week, natural number → date
nth working days after: date, list of wikidata item references (list of holidays), wikidata item reference (place) → date
Gregorian year
See
catalogue of year functions
for existing functions.
Morphological functions
morphology is the part of linguistics that studies how language parts are 'shaped' and change diachronically and when inflected. Hausa, Igbo, Malayalam, Bangla/Bengali and Dagbani are
focus languages
for Wikidata's lexicographic dataset, which is an important aspect of
Abstract Wikipedia
mul - Multiple languages
inputs: natural number (new numeric type) and language Z-number; output: 'singular', 'dual', 'paucal', 'plural', etc. as string
Doing...
(!) return grammatical number for an integer and language (
Z15977
):
Given an integer, what would the grammatical number be when we talk about how often something occurs? (result currently an English string)
State location using entity and class (
Z26570
but with a
Typed list (
Z881
of
Wikidata item reference (
Z6091
for the
location
input;
such as in "
Gaza war
(Q122962941)
is an
armed conflict
(Q350604)
in
Israel
(Q801)
and
Gaza Strip
(Q39760)
ase - American Sign Language
string: Stokoe to ase-
Sgnw
and vice-versa (consult
Slevinski
as to best approach)
bn - Bangla
bzs - Brazilian Sign Language
SignWriting
sample text
cy - Welsh
w:en:colloquial Welsh morphology
dag - Dagbani
de - German
tense * person * number for each verb
tenses: present, past, ...?
person: first, second, third
number: singular, plural
Doing...
third person singular present
second person singular preterite
en - English
English verb to agent noun (
Z11390
):
morpheme which takes a verb and returns the agent that does that verb
Verb -> agent noun, e.g. "dance"->"dancer"
Join English morphemes (extends
suffix English word (
Z13254
):
add any suffix to an English word with regular changes to spelling (monosyllabic or final-syllable stress is generally assumed)
to cases like re + en + able + er + s → re-enablers.
suffix English word (
Z13254
):
add any suffix to an English word with regular changes to spelling (monosyllabic or final-syllable stress is generally assumed)
will correctly join re-enable + ers or re- + enablers, but re + enablers → “renablers” (incorrect).
English morpheme agglutination (
Z13275
):
Repeated suffixing of initially empty string
tests the Reduce function to produce “detoxification” from a list of four morphemes (orchestrator limit exceeded with five). I doubt we’ll want to derive “toxify” from “toxic”, however.
Derive lemmas from a form. This is envisaged as the converse of Join English morphemes. The focus would be identifying the base form (the lexeme’s lemma) rather than further segmenting the lemma. For example, “underlay” should return “underlie” (for which it is the past participle) and the noun “underlay” (for which it is the lemma) and (perhaps) the verb “underlay”, which might be the tendency of an unproductive hen or the activity of a carpet-fitter. As this is a purely functional converse, every string will have itself as a possible lemma.
Generate
Numerical prefixes
of various kinds from a natural number input.
sort English adjectives (
Z19499
):
Sort a list of English adjectives into the correct order: quantity, opinion, size, physical quality, shape, age, colour, origin, material, type, purpose. Where equal, leave in original order.
Intro for geographical feature: Returns a intro sentence for a geographical feature.
Example 1: The
Centre for Fine Arts
is an
arts center
on
Coudenberg - Koudenberg
in
Mont des Arts - Kunstberg, City of Brussels
Belgium
Wikidata label = Centre for Fine Arts
instance of
(P31)
arts center
(Q2190251)
located in/on physical feature
(P706)
Coudenberg - Koudenberg
(Q13451667)
location
(P276)
Mont des Arts - Kunstberg
(Q115180808)
located in the administrative territorial entity
(P131)
Brussels
(Q239)
country
(P17)
Belgium
(Q31)
Example 2:
Olympus Mons
is a
mons
on
Mars
on
Tharsis
Amazonis quadrangle
and
Tharsis quadrangle
Wikidata label = Olympus Mons
instance of
(P31)
mons
(Q429088)
located on astronomical body
(P376)
Mars
(Q111)
located in/on physical feature
(P706)
Tharsis
(Q2170645)
location
(P276)
Amazonis quadrangle
(Q3054547)
Tharsis quadrangle
(Q3054525)
Example 3:
Princess Elisabeth Antarctica
is a
Antarctic research station
on
Utsteinen Nunatak
Antarctic Treaty area
Antartica
Wikidata label = Princess Elisabeth Antarctica
instance of
(P31)
Antarctic research station
(Q749622)
located in/on physical feature
(P706)
Utsteinen Nunatak
(Q7754959)
located in the administrative territorial entity
(P131)
Antarctic Treaty area
(Q21590062)
country
(P17)
none
continent
(P30)
Antarctica
(Q51)
eu - Basque
Basque language declension system in rather regular based on suffixes.
Here a few examples for Basque declension:
Basque plural noun (
Z18541
):
This function creates the plural for a noun in Basque
Basque ergative singular case declension (
Z18670
):
This function returns the singular ergative case for a noun (proper or not) in Basque language
Before implementing all of them, we may propose an overall classification that eases both the implementation and the future usage of the functions. Here a first try based on bibliography from the
Basque Language Academy
Personal pronouns: they can be treated as exceptions (e.g. "zuek -> zuei", etc.) together with proper noun declension, or as a separate case.
Determiners: they can be treated as exceptions (e.g. "hau" -> "honek", etc) together with common noun declension, or as a separated case
Grammatical cases:
Absolutive ("Nor"): indefinite, singular and plural
Ergative ("Nork"): indefinite, singular and plural
Dative ("Nori"): indefinite, singular and plural
Place and Time: we must distinguish animate (AN) and inanimate (IN)
Inessive IN ("Non"): indefinite, singular and plural
Inessive AN ("Norengan"): indefinite, singular and plural - It could be a composition of "Noren" + "-gan"
Place and time ("Nongo"): indefinite, singular and plural
Allative IN ("Nora"): indefinite, singular and plural
Allative AN ("Norengana"): indefinite, singular and plural - It could be a composition of "Noren/Norengan" + "-gan/-a"
Finished Allative AN ("Noraino"): indefinite, singular and plural - It could be a composition of "Nora" + "-ino"
Finished Allative AN ("Norengainaino"): indefinite, singular and plural - It could be a composition of "Noregana" + "-ino"
Right way Allative IN ("Noratz"): indefinite, singular and plural - It could be a composition of "Nora" + "-ntz"
Right way Allative AN ("Norenganantz"): indefinite, singular and plural - It could be a composition of "Norengana" + "-ntz"
Ablative IN ("Nondik"): indefinite, singular and plural
Ablative AN ("Norengandik"): indefinite, singular and plural
Rest of the cases:
Partitive ("Zerik"): indefinite
Possessive ("Noren"): indefinite, singular and plural
Sociative ("Norekin"): indefinite, singular and plural
Instrumental ("Zerez"): indefinite, singular and plural
Motivative ("Zerengatik"): indefinite, singular and plural
Destinative ("Norentzat"): indefinite, singular and plural - It could be a composition of "Noren" + "-tzat"
Special case:
Prolative ("Nortzat"): indefinite
To take into consideration:
Together with animate and inanimate classification, we should also consider if the noun is a proper noun ("izen berezia"). We can identify that automatically (e.g. check if written in Title case, but this may not be always possible like in the beginning of sentences), but a dedicated function may be preferred (or a boolean to the generic function saying it is a proper noun).
The main distinction is between noun ending by vowel or consonant that can be easily computed
fr - French
French masculine adjective to feminine (
Z11590
):
converts the masculine form of a French adjective to its equivalent feminine form (pre-1990 traditional orthography)
Masculine adjective -> feminine, e.g. "exact"->"exacte"
Conjugated verb => Infinitive, e.g. "alla" => "aller", "mordit" => "mordre"
ha - Hausa
A notated demo sentence ("Aishà taa jeefar dà kàren Indoo" ― "Aisha threw away Indo's dog") is available at
ig - Igbo
ldn - Láadan
section moved to
WF:human languages/Z1882
ml - Malayalam
nl - Dutch
Cardinals
Cardinal to number
Number to cardinal
Verbs
Conjugations
Morphology
Diminutive to root word
Belgian diminutive to root word
Root word to diminutive
Belgian root word to diminutive (-ke)
Plural diminutive to root word
Belgian plural diminutive to root word
Root word to plural diminutive
Belgian root word to plural diminutive (-kes)
kcg - Tyap
Tyap has six determiners/definite articles which determine the pronoun, number (1-5), etc. forms used.
ka & wu (basically for singular nouns and adjectives with a few exceptions)
hu & ji (for singular and plural nouns and adjectives)
ba & na (mainly for plural nouns.
Determiners come after nouns.
When an adjective comes before a noun, the determiner used is that of the adjective. E.g., a̱sham (ka) - (the) beautiful, kyang (hu) - (the) thing = a̱sham kyang (ka) - (the) beautiful thing.
Tyap has a non-uniform noun class system used for noun pluralization and conversion from one part of speech to another. E.g., a̱bwom (song) and bwom (to sing), a̱fufwuo (ears) and fufwuo (ear).
Affixation: Prefixes exist but suffixes hardly are found.
vgt - Flemish Sign Language
SignWriting encode
JhowieNitnek
talk
12:44, 18 January 2026 (UTC)
reply
Proposed functions requiring future types
Note these functions cannot be implemented properly until the needed types are requested and approved.
If one wishes to nevertheless attempt to define and implement them,
the functions and implementations should indicate prominently in their labels that their input/output types must be adjusted once support for the appropriate replacement types become available;
and
the functions should
not
be used in the implementations of any other functions, as the later adjustment of input/output types to appropriate replacements will break those implementations.
String manipulation functions
String analysis functions
count distance between two letters in given alphabet (default to 26-charcater western alphabet. case insensitive. e.g. "a" & "A" ⇒ 0; "K" & "N" ⇒ 3)
String encoding and decoding functions
(would be better with types representing a stream of bytes)
BASE45 encode
BASE45 decode
Hexadecimal UTF-8 encode ("ABC ₤" ⇒ "41 42 43 20 E2 82 A4")
Hexadecimal UTF-8 decode ("41 42 43 20 E2 82 A4" ⇒ "ABC ₤")
Decimal UTF-8 encode ("ABC ₤" ⇒ "65 66 67 32 226 130 164")
Decimal UTF-8 decode ("65 66 67 32 226 130 164" ⇒ "ABC ₤")
Octal UTF-8 encode ("ABC ₤" ⇒ "101 102 103 40 342 202 244")
Octal UTF-8 decode ("101 102 103 40 342 202 244" ⇒ "ABC ₤")
Binary UTF-8 encode ("ABC ₤" ⇒ "01000001 01000010 01000011 00100000 11100010 10000010 10100100")
Binary UTF-8 decode ("01000001 01000010 01000011 00100000 11100010 10000010 10100100" ⇒ "ABC ₤")
Unicode code point encode ("ABC ₤" ⇒ "41 42 43 20 20A4") -
Unicode code point encode hex (
Z10785
):
Takes a Unicode string and returns a space-separated list of hexadecimal Unicode code points.
Unicode code point decode ("41 42 43 20 20A4" ⇒ "ABC ₤")
Create regular expression object/string (i.e: "test" & "i" to /test/i)
Natural language functions
Choose singular or plural based on number (e.g. singularOrPlural("person",6") -> "people")
Note that there are also dual and other
grammatical numbers
in other languages.
魔琴
talk
18:54, 26 October 2023 (UTC)
reply
relevant interwiki link:
d:WD:property proposal/plural forms
Arlo Barnes
talk
04:15, 9 February 2024 (UTC)
reply
Was rejected.
The similar proposal
has grammatical number
(P13986)
was accepted, but per the comments on your proposal, just having that set (and
mapping it to one of our enums
) isn't sufficient since a language might have exceptions to its conjugation rules, or handle rational/real numbers in different ways.
Being able to make use of CLDR data might still be desirable to avoid hardcoding rules and exceptions into Functions.
YoshiRulz
talk
02:16, 18 December 2025 (UTC)
reply
This is duplicated with a suggestion above. There's some work done already:
Z15977
. We also have lightweight enums like
Grammatical number (singular / dual / plural) (
Z28215
now.
YoshiRulz
talk
21:11, 30 November 2025 (UTC)
reply
Cryptographic functions
(would be better with types representing a stream of bytes)
To do
MD2
MD2 Hashing (
Z10135
):
Description missing
To do
MD4
MD4 (
Z10136
):
Description missing
To do
MD5
MD5 (
Z10137
):
calculate Message Digest 5 (MD5) hash for given string
To do
RIPEMD-128
RIPEMD-128 (
Z10138
):
Description missing
To do
RIPEMD-160
RIPEMD-160 (
Z10139
):
Description missing
To do
BLAKE2b-160
BLAKE2b-160 (
Z10140
):
Description missing
To do
BLAKE2b-256
BLAKE2b-256 (
Z10141
):
Description missing
To do
BLAKE2b-384
BLAKE2b-384 (
Z10142
):
Description missing
To do
BLAKE2b-512
BLAKE2b-512 (
Z10143
):
Description missing
To do
BLAKE2s-128
BLAKE2s-128 (
Z10144
):
Description missing
To do
BLAKE2s-160
BLAKE2s-160 (
Z10145
):
Description missing
To do
BLAKE2s-224
BLAKE2s-224 (
Z10146
):
Description missing
To do
BLAKE2s-256
BLAKE2s-256 (
Z10147
):
Description missing
To do
SHA-224
SHA-224 (
Z10149
):
Description missing
To do
HMAC-SHA-256
To do
SHAKE-128
SHAKE128 (
Z10150
):
expandable output function (XOF) specified by NIST FIPS 202
To do
SHAKE-256
SHAKE256 (
Z10151
):
expandable output function (XOF) specified by NIST FIPS 202
To do
ChaCha20
ChaCha20 (
Z25376
):
Generate a ChaCha20 block from a key, a counter and a nonce value. The key is a 64 character hex string and both the counter and nonce are 64 bit integers that will be encoded as little-endian.
To do
X25519
X25519 (
Z25393
):
Multiply a point on Curve25519 by a scalar
To do
Keccak-f[1600]
Keccak-f[1600] (
Z25399
):
Keccak-f[1600] permutation specified in FIPS 202.
Date, time, and calendric functions
Discussion of types:
WF:type#Calendar types
Asgardian calendar
Base on the
online converter
; see
Asgardia
for context
Bengali calendar
Gregorian to Bengali date (Bangladesh) (
Z12926
):
Converts a Gregorian date to Bangla date per Bangladeshi calendar. Inputs: Year, Month, Day.
Chinese calendar
French Republican Calendar
decimalises and secularises the Gregorian
day names:
is the day name part of the French Republican Calendar 'rural' naming? (
Z13006
):
tests if input is one of the French-language names for days in the FRC
Not done
yet
Gregorian
widely used calendar derived from the Julian, basis for
ISO 8601
date to ISO week number
ISO week date
(Q2110154)
string to date
date to ISO 8601 string
Done
, see
date string (English) to ISO 8601 (
Z21842
):
Converts a date string in a non-ISO 8601 format to its equivalent ISO 8601 string. Input must use English or other format
. --
Sbb1413
talk
18:47, 21 January 2025 (UTC)
reply
date to year (yyyy)
date to month of the year (1-12)
date to month name (January-December)
date to day of the month (1-31)
date to hour of the day (0-23)
date to minutes (0-59)
date to seconds (0-59)
Named Day from Date or day of year
; Input type
: Date
; Output Type
: String.
; The initial use case was automated population of On The Day, based on various collections of Holidays, festival days and observances.
ShakespeareFan00
talk
19:35, 26 March 2025 (UTC)
reply
So If you gave it 2025-05-01 It said "All Fools Day" etc.. Possibly an additional input of enumrated type to indicate which data set to pull holidays, fesitvals and observances from.
ShakespeareFan00
talk
19:35, 26 March 2025 (UTC)
reply
Diary/calander Header function - Using the above and other date functions, generates a data set from a given date. Hence if you give it 2003-05-01 you get back a JOSN set contianing the {Day of week:String, Day in the Month, Observances} etc.
ShakespeareFan00
talk
19:35, 26 March 2025 (UTC)
reply
Holocene calendar
w:en:Holocene calendar#Conversion
Done
, see
Gregorian to Holocene year (
Z21913
):
Converts a given Gregorian year to Holocene year.
. --
Sbb1413
talk
13:30, 25 January 2025 (UTC)
reply
Indian national calendar
Islamic
a Lunar calendar, also called Hijri
Julian
mostly used by astronomers, some historians, and some Orthodox Christian denominations
Mesoamerican calendars
including civil and clerical forms
Persian
also called Jalali
Thai calendar
Hebrew calendar
Darian calendar
Proposed time-keeping system for Mars, requires Julian Date/Time to calculate and a month enumeration:
WF:type proposals#Something to think about
Basic numerical functions
round up ("1.289" & "2" ⇒ "1.29"; "5678" & "2" ⇒ "5700")
So if the number is floating point, round to n decimal places, and if not, round to n significant figures. Is that right?
BrightSunMan
talk
19:36, 24 December 2023 (UTC)
reply
Done
ceiling of rational number (
Z20053
ceiling (float64 to float64) (
Z21043
and
round rational to fixed decimal places, simplified (
Z27705
round to decimal places (float64) (
Z21047
round down
Done
floor of rational number (
Z20032
floor (float64 to integer) (
Z20841
return integer value (5678.678 ⇒ 5678)
Done
rational to nearest integer, even integer tiebreak (
Z19841
round float64 (ties to even, as Integer) (
Z26315
English cardinal (
Z13587
):
expresses a natural number in English words
(23 ⇒ "twenty-three")
Convert money from US$ to anything else
requires source of conversion rates, which is a hole in function-likeness
Arabic numeral to Etruscan numeral
Etruscan numeral to Arabic numeral
Data serialization functions
parse a string as
JSON
extract string from JSON object based on
JSONPath
{"name":"Alice"}
, "$.name" ⇒ "Alice")
Why not first convert a JSON string to an object, and then have a function that extracts fields based on JSONPath? Doing Stringly-typed things like this proposal as defined isn't a good idea.
0xDeadbeef
talk
16:16, 5 August 2023 (UTC)
reply
This seems to be a good idea, thanks! I moved and splitted the proposal accordingly. --
1-Byte
talk
09:51, 6 August 2023 (UTC)
reply
is it okay to go ahead to create this 'extract string from JSON object based on JSONPath' as a function
Dolphyb
talk
16:14, 15 February 2024 (UTC)
reply
Basic list/iterable functions requiring numeric types
Sum the elements of a numeric list -
sum the elements of a list of natural numbers (
Z14038
):
given a list of numeric values return the sum of all the values in the list otherwise return 0 when list is empty
Product of the elements of a numeric list
Done
product of list (Rational numbers) (
Z23909
product of list (natural numbers) (
Z13558
flatten untyped list (
Z12676
):
flatten an (untyped) list to limited depth
Slice of list elements: for the supplied list, return a list of elements that are at indexes between a supplied range n:m
Zero indexing is used (first element is index 0)?
n and m are are included in the range?
What happens if n and/or m are invalid indexes?
Done
take sub-sequence of list (
Z26556
):
clamps indices to valid range (1..=N); returns empty if end
start
Remove slice of elements from list: return the supplied list with elements between a supplied range of indexes removed
Zero indexing is used (first element is index 0)?
n and m are are included in the range?
What happens if n and/or m are invalid indexes?
Every nth element of list: returns every nth element of the supplied list
Done
every nth item of list starting with nth (
Z28735
):
Returns every nth item of a list. For example, "3" and a list of 10 items would return the 3rd, 6th, and 9th item.
Remove every nth element of list: removes every nth element of the supplied list -
sample n objects from list (return up to n
random
objects from the list)
Jaccard similarity coefficient (see
Weighted average. Supply a list of values, and a second list of the same length of their weights. Returns a weighted average
Example Input:
values = [10, 20, 30]
weights = [1, 2, 3]
Output:
23.33
Done
weighted average (floating point values) (
Z28066
):
Weighted Average = sum(value * weight) / sum(weight)
Lists must be equal length.
Geodetics functions
w:en:planetary coordinate system
w:en:well-known text representation of coordinate reference systems
Earth
convert coordinates outside of the ranges (-180, 180) for longitude and (-90, 90) for latitude to a canonical form
Plus Codes
to/from geocoordinates
functions should match the semantics of the
expected API
is valid Plus Code?
is shortened Plus Code?
is full Plus Code?
Plus Code from co-ordinates (
Z25963
):
only works with WGS84
co-ordinates from Plus Code
SW corner
),
shorten Plus Code
recover nearest Plus Code
implementations for JS and Python are provided, Apache 2.0 licenced, not sure how self-contained they are
most of the functions could also be implemented by composition
sample data is provided for testing (it's ~500 cases for each of encode/decode and ~50 cases for each of the others, but they're grouped nicely so maybe take 1 from each)
Mars
w:en:areography#Cartography and geodesy
convert coordinates outside of the ranges [0, 360) for longitude and (-90, 90) for latitude to a canonical form
Moon
w:en:selenography#Lunar cartography and toponymy
Unit conversion functions
Fahrenheit to Celsius (
Z15560
):
Converts Fahrenheit (°F) to Celsius (°C)
The function has two implementations now.
Redmin
talk
20:32, 20 February 2026 (UTC)
reply
Conversion function
: 2D Cartesian to 2D Polar
Input
: matrix [x,y]
Output: matrix [θ,r]
Short text
: Polar conversion of x,y to a polar space centred at 0,0 in the Cartesian.
Constraints: x,y,r are reals (float64), θ lies in the range -π<0<π (Sign determined in relation to standards used in STEM applications.
ShakespeareFan00
talk
14:30, 26 March 2025 (UTC)
reply
The companion could also be provided. As I never did Geodetic functions, I am not sure how Lat, Long to map projection would work , but useful.
ShakespeareFan00
talk
14:30, 26 March 2025 (UTC)
reply
See also
WF:Type proposals/complex128
YoshiRulz
talk
10:17, 1 December 2025 (UTC)
reply
Trigonometric functions
sine (float64, rad) (
Z16463
cosine (
Z12473
Input
: float64 Angle in radians.
Output
: float64 desired trignometric value
ShakespeareFan00
talk
19:40, 26 March 2025 (UTC)
reply
Rotate a 2D point about origin (
Z29125
Inputs: 2D Point (float64s, Reals, or perhaps
a single complex number
), angle (float64 or Real)
Output: 2D Point (matching the input type)
Not necessarily one single function; one can be created for each input type
WrenFalcon
talk
22:05, 31 July 2025 (UTC)
reply
Function proposal
: Decimalise angle of the form ('1:x' or '1 in x') to
% (in 100) or ‰ (in 1000)
Suggested name: gardient_decimal.
Input type: Integer ( The 1 is implied.). Lower Bound +1: Upper Bound: 1000 (for most practical situations?)
Output type: Real/float 64.
Proposer:
ShakespeareFan00
talk
19:05, 28 March 2025 (UTC)
reply
Color Functions
Colorspace Conversion
x,y,Y to sRGB (Illuminant D65).
Input
: 3tuple of float64,
Output: 3 tuple of integer, where 0>=r<=255, 0>=g<=255 0>=b<=255.
Convert a color specfied as 3 float64 values, from x,y,Y colorspace to sRGB or raise an "Out of Gaumt" exception.
ShakespeareFan00
talk
19:09, 7 April 2025 (UTC)
reply
Spectral Approximate from sRGB or XYZ values.
I'd like to see the techniques detailed here:
implemented in Wikifunctions as the provided spreadhseet later in the paper doesn't appear to work with Libre Office.
ShakespeareFan00
talk
19:32, 2 June 2025 (UTC)
reply
Subtractive color mix (Pigment style)
Implement the mixing function from Spectral.js (
)(MIT license), to allow 2 or more sRGB triplets to be mixed like pigment colors. This is different from the subtract colors function implemented previously.
Music Functions
It would be nice to have
12 equal temperament pitch class
and
12 equal temperament pitch
types, as they would be useful for calculating harmonies and melodies. The pitch classes could be stored as natural numbers from 0 to 11, and represented with symbols C, C♯, D, ..., B. The pitches could be stored as integers with -1 being B3, 0 being C4, 1 being C♯4, etc. Over time, we could expand the pitch class and pitch types to other temperaments and just intonation. As I'm new to Wikifunctions and my coding skills are next to zero, this is just a suggestion to the community. (edited)
CaffeineP
talk
14:48, 9 April 2025 (UTC)
reply
Yes… There are some notational challenges because of enharmonics as well as naming conventions varying by language/culture, so English A♯ is equivalent to German B and English B♭, for example. Ideally, I would want the (English) pitch class that is five semitones higher than G♭ to be displayed as C♭ rather than B.
Also, given some reference pitch like A4 = 440 Hz, we should be able to return the frequency in hertz of a given pitch and, conversely, the nearest pitch for a given frequency and its offset in cents (or whatever). The computation is a lot simpler than representing the result (or capturing how the result should be represented)!
GrounderUK
talk
20:08, 9 April 2025 (UTC)
reply
If you use the cardinal values for the pitches from the MIDI standard (or an extension to such, since they're limited to 0..<128) then you could make some of these functions already, no
type proposal
needed. Granted a lot of them would just be addition/subtraction. And if you semi-arbitrarily map A = 0, A# = 1, etc. then you could do all of them.
YoshiRulz
talk
10:33, 1 December 2025 (UTC)
reply
12-ET Pitch Class of a Pitch
: Return the 12 equal temperament pitch class of a given 12 equal temperament pitch. For example, C4 returns C.
12-ET Pitch based on Pitch Class
: Return a 12 equal temperament pitch based on a given 12 equal temperament pitch class and a given integer. For example, C and 4 return C4.
Interval between 12-ET Pitch Classes in Semitones
: Get the interval in semitones between two 12 equal temperament pitch classes, always assuming that the first is lower than (or the same as) the second, and the interval is less than an octave. For example, C and B return 11, while B and C return 1.
Interval between 12-ET Pitches in Semitones
: Get the interval in semitones between two 12 equal temperament pitches. For example, C4 and B3 return -1, while C3 and B4 return 23.
difference between pitches in semitones (
Z25219
):
calculate the number of semitones between two musical pitches
Raise 12-ET Pitch Class by Semitones
: Get a new 12 equal temperament pitch class through raising a given pitch class by the provided number of semitones. For example, raising B by 1 semitone returns C.
transpose pitch (
Z25407
):
transposes a musical pitch from the standard chromatic scale up or down by semitones
Lower 12-ET Pitch Class by Semitones
: Same as above, but lower the pitch class instead of raising it.
transpose pitch (
Z25407
):
transposes a musical pitch from the standard chromatic scale up or down by semitones
Raise 12-ET Pitch by Semitones
: Get a new 12 equal temperament pitch through raising a given pitch by the provided number of semitones. For example, raising B3 by 1 semitone returns C4.
Lower 12-ET Pitch by Semitones
: Same as above, but lower the pitch instead of raising it.
Frequency of a 12-ET Pitch
: Return a float64 frequency in Hz based on the provided 12 equal temperament pitch (and possibly a reference pitch with its frequency; if not provided, take default A4 = 440 Hz).
frequency of pitch in A440 equal temperament (
Z25217
):
calculates the frequency (in hertz) of a musical pitch in twelve-tone equal temperament, using the A440 pitch standard
Approximate 12-ET Pitch Class based on Frequency
: Return a 12 equal temperament pitch class approximately based on the provided frequency in Hz.
Approximate 12-ET Pitch based on Frequency
: Return a 12 equal temperament pitch approximately based on the provided frequency in Hz.
SVG Functions
I would be nice to generate SVG (a XML-based vector image format which is basically a long string), it could allow to replace a lot of images on Commons or templates/tools. Here some examples:
create simple forms,
create graphs (line graph/bar graph for population or for production, elections diagrams like
File:1900Hawaii.svg
, etc.),
create more complex visualisation like genealogical trees,
create coat of arms (?),
etc.
Cheers,
VIGNERON
talk
10:47, 23 April 2025 (UTC)
reply
VIGNERON
: Eventually that is something we might support, but there'll be nothing any time soon. It has a number of complex security and scalability concerns, sadly.
Jdforrester (WMF)
talk
13:21, 23 April 2025 (UTC)
reply
Jdforrester (WMF)
thanks. I talked about it for the last Corner but I wanted to leave a record here, if we have time, maybe I'll use that time to write some things to prepare (like listing templates and tools on the Wikimedia projects that generate SVG or visualisations). Cheers,
VIGNERON
talk
15:28, 23 April 2025 (UTC)
reply
Of course! I've explicitly added a section on this here:
Wikifunctions:Embedded function calls#Non-text output
— hope that helps assure you that we're thinking about it.
Jdforrester (WMF)
talk
21:40, 23 April 2025 (UTC)
reply
Biology
Taxon functions
A taxon type could be useful, as could a taxon rank enum (
instance of
(P31)
taxonomic rank
(Q427626)
). --
WrenFalcon
talk
16:49, 22 September 2025 (UTC)
reply
Wikidata item representing taxon rank (
instance of
(P31)
taxonomic rank
(Q427626)
) is at genus level or below
Should(?) be possible with the current Wikidata functionality, from what I understand. See
Wikifunctions:Project chat#Taxon rank function(s)
for a more detailed explanation. --
WrenFalcon
talk
23:27, 16 May 2025 (UTC)
reply
compare taxon ranks
Cases: a < b, a == b, a > b, undetermined/incomparable (if a or b are clades, this should be returned/used)
get taxon code of nomenclature (
code of nomenclature
(P944)
is parent taxon of / is child taxon of
is parent taxon of(Taxon a, Taxon b) => b.parent == a OR is parent taxon of(a, b.parent)
format taxon name (according to relevant rules of nomenclature)
Include author and year citation? Maybe page too, if present?
Object / type / function functions
External function lists
WF:importing
Retrieved from "
Category
Maintenance
Wikifunctions
Suggest a function
Add topic