Module:Params/doc/examples/array/doc

From Wikipedia, the free encyclopedia
This is the current revision of this page, as edited by imported>Grufo at 13:09, 30 September 2025. The present address (URL) is a permanent link to this version.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This example template is an almost-exact clone of the {{Array}} template, written using Module:Params. It handles five functions: count, get, pos, math and sort.

{{module:params/doc/examples/array|<Function>|<Array items>|<Delimiter>|<Property>|Parameters (optional)}}

5th parameter only valid with pos function when limiting multiple outputs to a single position.

Functions

[edit source]
Count

Will count the total number of items in the array using the designated separator. Leading or trailing separators are stripped.

Get

Will get the Nth item in the array, numeric value only. Can use negative value to work backwards. Last or -1 will get end item. Invalid value returns error.

Pos

Will retrieve the position in array of the search item. If duplicates are found, will output all positions delimited by comma. Output can be limited by specifying a 5th parameter.

{{module:params/doc/examples/array|Pos|<Array items>|<Delimiter>|<Search Term>|<Nth occurrence> (optional)}}
Math

Will do calculations on the array items if all numeric. Options are sum (sum of all item numbers), min and max.

Sort

Sort items in the array, ascending/chronological, numeric first.

See also

[edit source]