Fandom Developers Wiki
Advertisement

This article is a stub.

You can help the Fandom Developers Wiki by expanding it.

ListFunctions is a module that provides some functions for working with lists. It was designed to perfectly combine with Variables, Arrays, and DPL3 ({{#dplvar}}) extensions. It also trims all list's items and removes empty values.

Installation

Usage

lstSeparator

{{#invoke:ListFunctions|lstSeparator|<input list>|<input separator>|<output separator>}}
Replaces one list's separator with another.
input list — string
input separator — string or character
output separator — string or character

Examples

Code Result
{{#invoke:ListFunctions|lstSeparator|1, 2, 3, 4|,|/}} 1/2/3/4
{{#invoke:ListFunctions|lstSeparator|1, 2, , 4|,|/}} 1/2/4
{{#invoke:ListFunctions|lstSeparator|1, 2, 3, 4|,|,}} 1,2,3,4

lstCount

{{#invoke:ListFunctions|lstCount|<input list>|<input separator>}}
Counts all items in a list (excluded empty values).
input list — string
input separator — string or character

Examples

Code Result
{{#invoke:ListFunctions|lstCount|1, 2, 3, 4|,}} 4
{{#invoke:ListFunctions|lstCount|aaa, bbb, aaa, ccc|,}} 4
{{#invoke:ListFunctions|lstCount|1, 2, , 4|,}} 3
{{#invoke:ListFunctions|lstCount|1, 2, 3, 4, 10|,}} 5

lstIndex

{{#invoke:ListFunctions|lstIndex|<input list>|<input separator>|<index>}}
Retrieve the N-th element in a list (excluded empty values). If the index is negative, it returns the same value as the $list_len - abs($index).
input list — string
input separator — string or character
index — number

Examples

Code Result
{{#invoke:ListFunctions|lstIndex|1, 2, 3, 4|,|1}} 1
{{#invoke:ListFunctions|lstIndex|aaa, bbb, aaa, ccc|,|-2}} aaa
{{#invoke:ListFunctions|lstIndex|aaa, bbb, aaa, ccc|,|-1}} ccc
{{#invoke:ListFunctions|lstIndex|1, 2, , 4|,|3}} 4

lstSub

{{#invoke:ListFunctions|lstSub|<input list>|<input separator>|<output separator>|<start index>|<the result list's length>}}
N/A
input list — string
input separator — string or character
output separator — string or character
start index — number
the result list's length — number

Examples

Code Result
{{#invoke:ListFunctions|lstSub|1, 2, 3, 4|,|/|1|3}} 1/2/3
{{#invoke:ListFunctions|lstSub|a, b, c, d, e, f|,|,|2|4}} b,c,d,e
{{#invoke:ListFunctions|lstSub|a, b, c, d, e, f|,|,|-4|2}} c,d
{{#invoke:ListFunctions|lstSub|a, b, c, d, e, f|,|,|-4|-2}}
{{#invoke:ListFunctions|lstSub|1, 2, , 4|,|,|2|2}} 2,4

lstFind

{{#invoke:ListFunctions|lstFind|<item>|<input list>|<input separator>|<case sensitive>}}
N/A
item — string
input list — string
input separator — string or character
case sensitive — "cs" (turn on case sensitivity) (optional)

Examples

Code Result
{{#invoke:ListFunctions|lstFind|1|1, 2, 3, 4|,}} 1
{{#invoke:ListFunctions|lstFind||1, 2, 3, , 4|,}}
{{#invoke:ListFunctions|lstFind|aaa|AAA, aaa, BBB, bbb, ccc|,}} AAA
{{#invoke:ListFunctions|lstFind|aaa|AAA, aaa, BBB, bbb, ccc|,|cs}} aaa
{{#invoke:ListFunctions|lstFind|aAa|AAA, aaa, BBB, bbb, ccc|,|cs}}

lstApp

{{#invoke:ListFunctions|lstApp|<input list>|<input separator>|<item>}}
N/A
input list — string
input separator — string or character
item — string

Examples

Code Result
{{#invoke:ListFunctions|lstApp|1, 2, 3, 4|,|5}} 1,2,3,4,5
{{#invoke:ListFunctions|lstApp|1, 2, 3, , 4|,|10}} 1,2,3,4,10

lstPrep

{{#invoke:ListFunctions|lstPrep|<item>|<input separator>|<input list>}}
N/A
item — string
input separator — string or character
input list — string

Examples

Code Result
{{#invoke:ListFunctions|lstPrep|5|,|1, 2, 3, 4|,}} 5,1,2,3,4
{{#invoke:ListFunctions|lstPrep|10|,|1, 2, 3, , 4|,}} 10,1,2,3,4

lstJoin

{{#invoke:ListFunctions|lstJoin|<first input list>|<first input separator>|<second input list>|<second input separator>|<output separator>}}
N/A
first input list — string
first input separator — string or character
second input list — string
second input separator — string or character
output separator — string or character

Examples

Code Result
{{#invoke:ListFunctions|lstJoin|5/6/7|/|1, 2, 3, 4|,|,}} 5,6,7,1,2,3,4
{{#invoke:ListFunctions|lstJoin|10|,|1, 2, 3, , 4|,|,}} 10,1,2,3,4

lstUniq

{{#invoke:ListFunctions|lstUniq|<mode>|<input list>|<input separator>|<output separator>|<case sensitive>}}
N/A
mode — "cnt" (turns on "count" mode) (optional)
input list — string
input separator — string or character
output separator — string or character
case sensitive — "cs" (turn on case sensitivity) (optional)

Examples

Code Result
{{#invoke:ListFunctions|lstUniq||1/2/3/4|/|,}} 1,2,3,4
{{#invoke:ListFunctions|lstUniq|cnt|1/2/3/4|/|,}} 4
{{#invoke:ListFunctions|lstUniq||AAA, aaa, BBB, ccc, CCC|,|,}} AAA,BBB,ccc
{{#invoke:ListFunctions|lstUniq|cnt|AAA, aaa, BBB, ccc, CCC|,|,}} 3
{{#invoke:ListFunctions|lstUniq||AAA, aaa, BBB, bbb, ccc, ccc|,|,|cs}} AAA,aaa,BBB,bbb,ccc
{{#invoke:ListFunctions|lstUniq|cnt|AAA, aaa, BBB, bbb, ccc, ccc|,|,|cs}} 5

lstSrt

{{#invoke:ListFunctions|lstSrt|<input list>|<input separator>|<output separator>|<numeric>|<reversed>}}
N/A
mode — "cnt" (turns on "count" mode) (optional)
input list — string
input separator — string or character
output separator — string or character
numeric — "y" (if the list is numeric) (optional)
reversed — "y" (reverse list) (optional)

Examples

Code Result
{{#invoke:ListFunctions|lstSrt|1, 5, 2, 8, 99, 33, 4, 3, 7, 0|,|/}} 0/1/2/3/33/4/5/7/8/99
{{#invoke:ListFunctions|lstSrt|1, 5, 2, 8, 99, 33, 4, 3, 7, 0|,|/|y}} 0/1/2/3/4/5/7/8/33/99
{{#invoke:ListFunctions|lstSrt|1, 5, 2, 8, 99, 33, 4, 3, 7, 0|,|/||y}} 99/8/7/5/4/33/3/2/1/0
{{#invoke:ListFunctions|lstSrt|1, 5, 2, 8, 99, 33, 4, 3, 7, 0|,|/|y|y}} 99/33/8/7/5/4/3/2/1/0

lstMap

{{#invoke:ListFunctions|lstMap|<input list>|<input separator>|<token>|<pattern>|<output separator>|<mode>}}
N/A
input list — string
input separator — string or character
token — string or character
pattern — string
output separator — string or character
mode — "np" (no preprocess, decreases the time to invoke the function) (optional)

Examples

Code Result
{{#invoke:ListFunctions|lstMap|1, 2, 3|,|@@@@|Number: @@@@|/|np}} Number: 1/Number: 2/Number: 3
{{#invoke:ListFunctions|lstMap|AjaxBatchDelete, AjaxRC, AjaxPoll, AjaxUndo|,|@@@@|[[@@@@]]|,|np}} AjaxBatchDelete,AjaxRC,AjaxPoll,AjaxUndo
{{#invoke:ListFunctions|lstMap|first, second, third|,|@@@@|{{L10n|l10n|@@@@}}|/|np}} //
{{#invoke:ListFunctions|lstMap|first, second, third|,|@@@@|{{L10n|l10n|@@@@}}|/}} //
{{#invoke:ListFunctions|lstMap|first, second, third|,|@@@@|{{((}}L10n{{!}}l10n{{!}}@@@@{{))}}|/|np}} l10n|first}}/{{L10n|l10n|second}}/{{L10n|l10n|third}}
{{#invoke:ListFunctions|lstMap|first, second, third|,|@@@@|{{((}}L10n{{!}}l10n{{!}}@@@@{{))}}|/}} first/second/third


Text above can be found here (edit)
Advertisement