Jump to content

Modulus:Params/doc/en/examples/array

E Vicipaedia
Icon documentationis Documentatio moduli[ostende] [recense] [historiam inspice] [purga]

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

[fontem recensere]
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.