Jump to content

Abstract Wikipedia/Early function examples/tr

From Meta, a Wikimedia project coordination wiki
This page is a translated version of the page Abstract Wikipedia/Early function examples and the translation is 5% complete.

This is a list of possible examples for functions that might or might not be suitable for the function wiki. Note that the ultimate authority of what is and is not suitable will be with the community, and this list of examples is not meant to make a decision on that. Also, neither the names nor the signatures of the functions are meant to be perfect, but really just sketches.

List of proposed functions

  • multiply : integer, integer ➝ integer
  • factorize : positive integer ➝ list(positive integer)
  • percent change : quantity, quantity ➝ percentage
  • interest : quantity(currency), timespan, percentage ➝ quantity
  • payment per period : quantity(currency), timespan, percentage, timespan ➝ quantity
  • and : boolean, boolean ➝ boolean
  • any : list(boolean) ➝ boolean
  • and : kleenean, kleenean ➝ kleenean
  • length : string ➝ integer
  • type of : any ➝ type
  • format : integer, style ➝ string
  • reverse : string ➝ string
  • rot13 : string ➝ string
  • hash sha256 : string ➝ sha256
  • validate hash : string, sha256 ➝ boolean
  • validate check digit : isbn13 ➝ boolean
  • capitalize : string ➝ string
  • letter histogram : string ➝ list(pair(character, positive integer))
  • head(T) : list(T) ➝ T
  • filter(T) : list(T), function(T ➝ boolean) ➝ list(T)
  • number of arguments : function(any ➝ any) ➝ integer
  • is empty(T) : list(T) ➝ boolean
  • convert : julian calendar date ➝ gregorian calendar date
  • add : julian calendar date, timespan ➝ julian calendar date
  • day of week : gregorian calendar date ➝ weekday
  • convert(T) : quantity(T), unit(T) ➝ quantity(T)
  • larger(T) : quantity(T), quantity(T) ➝ kleenean
  • distance : geocoordinate, geocoordinate ➝ quantity(length)
  • distance : city, city ➝ quantity(length)
  • distance : planet, planet, gregorian calendar date ➝ quantity(length)
  • size : geoshape ➝ quantity(area)
  • volume of torus : quantity(length), quantity(length) ➝ quantity(volume)
  • age at birth of first known child : person ➝ timespan
  • filter dishes by allergen : list(dish), allergen ➝ list(dish)
  • transpose : melody, key ➝ melody
  • head of state at birth : person ➝ person
  • filter by tomorrow’s heights : list(location), quantity(temperature) ➝ list(location)
  • most specific common taxon : taxon, taxon ➝ taxon
  • lives in : taxon, location ➝ kleenean
  • lived contemporary : taxon, taxon ➝ kleenean
  • lived contemporary : person, person ➝ kleenean
  • sum of populations in counties : state ➝ quantity
  • pie chart : list(pair(label, integer)), width ➝ image
  • answer to everything : nothing ➝ integer
  • dominant color : image ➝ rgb color
  • does Wikipedia link : qid, qid, language code ➝ boolean
  • height : image ➝ integer
  • resize : image, integer, integer ➝ image
  • mask filter : image, bitmask ➝ image
  • demonym : location ➝ noun
  • plural : English noun ➝ string
  • plural : German noun, German case ➝ string
  • make clause : noun phrase, verb phrase, gregorian calendar date ➝ clause
  • render : clause, language ➝ string


Örneklerin okunuşu

The syntax used above is only a possible compact representation. The actual user interface of the wiki of functions may show this in different ways (see the early mockups for examples).

  • First comes a possible English label of the function, shown with bold characters (it may be translatable later in the wiki of functions or Wikidata, and cautiously used instead of the internal and unambiguous ZID — that is used at runtime by the evaluator engine or for compositing other functions — keeping in mind that these simple names may be ambiguous and could require scoping or could be aliased differently for use in different implementation languages), followed by a colon :.
    • When the function name has a pair of round parentheses () following it before the colon, it means that the function itself is generic and based on a variable input type T.
  • It is then followed by a list of the types of the input arguments of the function, separated by commas , and then followed by an arrow and the type of the output value.
    • Note that types are specified by their descriptive name in English for now, but they will also be described as ZObjects, with translatable labels and an internal unambiguous ZID.
    • When a type has round parentheses (), it is a type function that returns a type further specified by the argument in the parentheses.
    • Possible errors (or exceptions) are not listed for now, but may be specified later with their own semantics (possibly by using a generic type constructor describing variant types for the result).
  • Constraints for values of the given input or output types are not specified. They may be described later by creating subtypes/derived types, for example:
    • the integer type may be specified as a subtype of a more general number type;
    • the byte type may be a specified subtype of the integer type;
    • the noun type may be a specified subtype of the string type, or more probably of a monolingual text type carrying an additional language code property, and specified by a generic type constructor (a kind of function whose input arguments may be other types or values);
    • the quantity type may be specified as a generic type constructor taking an input argument as a value or type, specifying the kind of measurement or a physical dimension, or other input arguments specifying a projection (geometric transforms and axis) and a reference object, separately from the specification of the measurement unit (this could be useful notably for geographic coordinates, temperatures, or qualifications for a specific jurisdiction): they can be defined as derived types using their own generic type constructor;
    • the location and person types may be also specified as a generic type constructor taking one or several several input arguments for specifying many required or optional properties, possibly by referencing other objects with their own suitable types.
  • For now, nothing indicates the default values for input arguments (when one of them is omitted), or if the return values are bound to the input arguments, or if the input arguments are modified when they are referenced (for now we'll assume a pure functional model where all inputs and outputs are independent of each other).
  • As well, the textual representation of constant values may depend on the specification of type conversion functions (including parsers or renderers for a given language specified as an input argument or as part of a runtime environment passed explicitly as an additional argument, or implicitly with some default).