Abstract Wikipedia/Early function examples

From Meta, a Wikimedia project coordination wiki
Jump to navigation Jump to search

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.

  1. multiply: integer, integer ➝ integer
  2. factorize: positive integer ➝ list(positive integer)
  3. percent change: quantity, quantity ➝ percentage
  4. interest: quantity(currency), timespan, percentage ➝ quantity
  5. payment per period: quantity(currency), timespan, percentage, timespan ➝ quantity
  6. and: boolean, boolean ➝ boolean
  7. any: list(boolean) ➝ boolean
  8. and: kleenean, kleenean ➝ kleenean
  9. length: string ➝ integer
  10. type of: any ➝ type
  11. format: integer, style ➝ string
  12. reverse: string ➝ string
  13. rot13: string ➝ string
  14. hash sha256: string ➝ sha256
  15. validate hash: string, sha256 ➝ boolean
  16. validate check digit: isbn13 ➝ boolean
  17. capitalize: string ➝ string
  18. letter histogram: string ➝ list(pair(character, positive integer))
  19. head(T): list(T) ➝ T
  20. filter(T): list(T), function(T ➝ boolean) ➝ list(T)
  21. number of arguments: function(any ➝ any) ➝ integer
  22. is empty(T): list(T) ➝ boolean
  23. convert: julian calendar date ➝ gregorian calendar date
  24. add: julian calendar date, timespan ➝ julian calendar date
  25. day of week: gregorian calendar date ➝ weekday
  26. convert(T): quantity(T), unit(T) ➝ quantity(T)
  27. larger(T): quantity(T), quantity(T) ➝ kleenean
  28. distance: geocoordinate, geocoordinate ➝ quantity(length)
  29. distance: city, city ➝ quantity(length)
  30. distance: planet, planet, gregorian calendar date ➝ quantity(length)
  31. size: geoshape ➝ quantity(area)
  32. volume of torus: quantity(length), quantity(length) ➝ quantity(volume)
  33. age at birth of first known child: person ➝ timespan
  34. filter dishes by allergen: list(dish), allergen ➝ list(dish)
  35. transpose: melody, key ➝ melody
  36. head of state at birth: person ➝ person
  37. filter by tomorrow’s heights: list(location), quantity(temperature) ➝ list(location)
  38. most specific common taxon: taxon, taxon ➝ taxon
  39. lived contemporary: taxon, taxon ➝ kleenean
  40. lived contemporary: person, person ➝ kleenean
  41. sum of populations in counties: state ➝ quantity
  42. pie chart: list(pair(label, integer)), width ➝ image
  43. answer to everything: nothing ➝ integer
  44. dominant color: image ➝ rgb color
  45. does Wikipedia link: qid, qid, language code ➝ boolean
  46. height: image ➝ integer
  47. resize: image, integer, integer ➝ image
  48. mask filter: image, bitmask ➝ image
  49. demonym: location ➝ noun
  50. plural: English noun ➝ string
  51. plural: German noun, German case ➝ string
  52. make clause: noun phrase, verb phrase, gregorian calendar date ➝ clause
  53. render: clause, language ➝ string

How to read the examples: first comes the English label of the function, followed by a colon (:), followed by a comma separated list of the types of the input arguments of the function, followed by an arrow (➝) and the type of the output value. Possible errors are not listed. When a type has round parentheses (()), it is a type function that returns a type further specified by the argument in the parentheses. When the function name has a round parentheses following it, it means that the function itself is generic and based on the input value T.