Wikifunctions:Suggest a function

Do you have an idea for a new function? Suggest it here! It may help to refer to our glossary.

You can go and create a function right away if you have the user-rights, and it aligns with other work.

Note that for now we only support strings, Booleans and lists as input and output types of functions. More types are coming in the next few months.

Once created, consider adding new Functions to the catalogue.

Proposed functions requiring only available types (string, Boolean, list)

String

String character discard functions

String character replacement functions

String search functions

String escaping and unescaping functions

String encoding and decoding functions

String presentation functions

String colour notation functions

String notation validation checks

String validation checks

String analysis functions

Monolingual text

String Wikitext operations

  •   Done italicise in Wikitext (Z11019) italicise (ABC -> ''ABC''), careful if the input has wikitext special characters in it
  •   Done bold in Wikitext (Z11139) bold (ABC -> '''ABC'''), careful if the input has wikitext special characters in it
  • Escape all special characters in a string so that they don't become functional when in Wikitext. (Is this possible? Or would it always be better to wrap with <nowiki></nowiki>?)

List

Basic list/iterable functions

  • right fold (Z12753): combine the first element with the result of recursively combining the rest, according to a combining function
  • left fold (Z12781): combine the result of recursively combining the rest, with the last element, according to a combining function
  • group

Complex list functions

  • all distinct permutations (Z12745): returns a list of all distinct permutations of the input list, each is itself a list
  • zip lists together: for [ A .. Z ] and [ 1 .. 26 ] return [ [ A, 1 ], [ B, 2 ], .. ]
    • Unsure what happens if input lists are of different lengths.
    • If possible this function should be able to zip more than 2 lists together... 3, 4, n? Perhaps the input should be list(list, list, list, list, ..).

CSV list operations

  •   Done csv to list of strings (Z12794): Converts a validly formatted (RFC 4180) comma-separated value series into a valid list of strings (not including the commas or row start or row end characters), where any whitespace and quotes are unchanged. Be careful to validly render CSV with quoted fields.
  • list of strings to csv

Functions with functions as arguments

  • Reduce Function (Z876): iterates the application of a two-parameter function, the first parameter uses the initial object or the previous result, the second parameter uses the next item on the list
  • right fold (Z12753): combine the first element with the result of recursively combining the rest, according to a combining function
  • left fold (Z12781): combine the result of recursively combining the rest, with the last element, according to a combining function
  • is sorted (Z13322): checks if a list is in order such that a comparator function returns true when each sequential pair of items are passed in as arguments
  • sort, by a given function
  • test whether certain functions have specific properties of homogeneous relations for particular lists/sets
    is identity relation over elements of list (Z13419): I = {(x, x) | x ∈ X}; that is, x1Ix2 holds if and only if x1 = x2. See https://en.wikipedia.org/wiki/Homogeneous_relation
  • remove first element matching filter from list

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.

ase - American Sign Language

  • string: Stokoe to ase-Sgnw and vice-versa (consult @Slevinski: as to best approach)

bn - Bangla

cy - Welsh

w:en:colloquial Welsh morphology

dag - Dagbani

de - German

en - English

  • English verb to agent noun (Z11390) Verb -> agent noun, e.g. "dance"->"dancer"
  •   Done English nominative to accusative (Z11651): converts a nominative (subject) pronoun to the accusative (objective) case
  •   Done Suffix English word (Z13254): Add any suffix to an English word with regular changes to spelling
  • Join English morphemes (extends Suffix English word (Z13254) to cases like re + en + able + er + s → re-enablers. Suffix English word (Z13254) will correctly join re-enable + ers or re- + enablers, but re + enablers → “renablers” (incorrect). English morpheme agglutination (Z13275) 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.

fr - French

ha - Hausa

A notated demo sentence ("Aishà taa jeefar dà kàren Indoo" ― "Aisha threw away Indo's dog") is available at http://intent.xigt.org

ig - Igbo

ldn - Láadan

section moved to WF:human languages/Z1882

ml - Malayalam

Proposed functions requiring future types

Note these functions cannot be implemented yet as Wikifunctions currently only supports Boolean and String types for function definitions.

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)
  •   Done Hamming distance between two strings of equal length, e.g. "Wikipedia" & "Wikimedia" ⇒ 1. - (!) hamming distance between two strings (Z11328)
  • Levenshtein distance between two strings (e.g. "kitten" to "sitting" => 3 : kitten > sitten > sittin > sitting)

String encoding and decoding functions

(would be better with types representing a stream of bytes)

Natural language functions

Cryptographic hash functions

(would be better with types representing a stream of bytes)

Colour functions

  • return colour contrast ratio (per [1]) of two RGB colours (provided as strings e.g. "#FF0000")

Date, time, and calendric functions

Note: time type not yet supported, use string

Bengali calendar

Gregorian to Bangla (Z12926): Returns the Bangla equivalent date of a Gregorian date format. The input fields represent the Year, month, and day, respectively.

Chinese calendar

French Republican Calendar

decimalises and secularises the Gregorian

Gregorian

widely used calendar derived from the Julian, basis for ISO 8601

Indian national calendar

Islamic

a solar 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

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[reply]
  • round down
  • return integer value (5678.678 ⇒ 5678)
  • decode Roman numerals ("X" ⇒ 10; 2023 ⇒ MMXXIII)
      Done : (!) Roman to Arabic numeral (Z11023): Convert a Roman numeral to Arabic numeral
  • encode as Roman numerals (10 ⇒ "X"; MMXXIII ⇒ 2023)
      Done : (!) Arabic to Roman numeral (Z11022): Convert a positive integer [1, 4999] to roman numeral
  • English cardinal (23 ⇒ "twenty-three")
  • English ordinal (23 ⇒ "twenty-third")
  •   Done: Body Mass Index (80kg and 1.80m ⇒ 24)
  • Convert money from US$ to anything else
    • requires source of conversion rates, which is a hole in function-likeness
  • Kronecker delta (Boolean: 1 if the inputs are equal, 0 otherwise)
  • Arabic numeral to Etruscan numeral
  • Etruscan numeral to Arabic numeral

Data serialization functions

Basic list/iterable functions requiring numeric types

  • Sum the elements of a numeric list
  • Product of the elements of a numeric list
  • (!) size of a list (Z12681): number of objects on a list, currently returned as a string
  • (!) flat a list (Z12676): no description
  • 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?
  • 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?
  •   Done First n elements of list: return a list of the first n elements of a supplied list - get the first n elements of a list (Z13366)
  •   Doing... Remove first n elements of list: returns the supplied list without the first n elements - remove first n elements of list (Z13369) (Todo: add more tests)
  •   Doing... Last n elements of list: return a list of the last n elements of a supplied list - get the last n elements of a list (Z13362) (Todo: add more tests)
  •   Done Remove last n elements of list: returns the supplied list without the last n elements - remove last n elements of a list (Z13373)
  • Every nth element of list: returns every nth element of the supplied list
  •   Done - get the nth element of a list (Z13397): When given a valid index return the nth element of the supplied list otherwise return nothing
  • Remove every nth element of list: removes every nth element of the supplied list -
  •   Done remove the nth element from a list (Z13429): When given a valid index remove the element at the position and return the supplied list otherwise return nothing
  • sample n objects from list (return up to n random objects from the list)
  • Jaccard similarity coefficient (see https://en.wikipedia.org/wiki/Jaccard_index)

External function lists