Module:Sequence/doc
This is a documentation subpage for Module:Sequence. It contains usage information, categories and other content that is not part of the original module page. |
{{[[Module:{{{1}}}|#invoke:{{{1}}}]]|function}}
This module is intended to provide access to basic sequence functions.
Most of the functions provided here can be invoked with named parameters, unnamed parameters, or a mixture. If named parameters are used, Mediawiki will automatically remove any leading or trailing whitespace from the parameter. Depending on the intended use, it may be advantageous to either preserve or remove such whitespace.
Global options
[edit]- ignore_errors
- If set to 'true' or 1, any error condition will result in an empty string being returned rather than an error message.
- error_category
- If an error occurs, specifies the name of a category to include with the error message. The default category is Category:Errors reported by Module Sequence.
- no_category
- If set to 'true' or 1, no category will be added if an error is generated.
len
[edit]This function returns the length of the target sequence.
Usage:
{{#invoke:Sequence|len|target_sequence}}
OR
{{#invoke:Sequence|len|s= target_sequence }}
Parameters:
- s
- The sequence whose length to report
idx
[edit]This function returns a single element from the target sequence at index idx.
Usage:
{{#invoke:Sequence|pos|target_sequence|index_value}}
OR
{{#invoke:Sequence|pos|target= target_sequence |idx= index_value }}
Parameters:
- target
- The sequence to use
- idx
- The index for the element to return
The first element has an index value of 1.
A requested index value of zero, or a value greater than the length of the sequence returns an error.
some
[edit]This function returns a number of elements from the target sequence. The elements' indices are given as a comma-separated list, and are output separated by the given separator (default: comma)
Usage:
{{#invoke:Sequence|some|target_sequence|index_list|separator}}
OR
{{#invoke:Sequence|some|target=target_sequence|idxList=index_list|sep=separator}}
Parameters
- target
- The sequence to use
- idxList
- The index for the element to return
- sep
- The character sequence to separate output elements
The first element has an index value of 1.
A requested index value of zero, or a value greater than the length of the sequence returns an error.