Functions for Lists

"It's still web development, it's just way easier!"

Lists

  • <#list = "b,c,a">
  • <#list2 = "b;c;a">
  • <#pairs = "b=5,a=3,c=1">
  • <#dupe = "a,b,b,c">
  • <#dupe2 = "a=1,b=2,b=3,c=1">
  • <#tenlist = "1,2,3,4,5,6,7,8,9,10">
  • <#unsorted = "5,10,1,100,5">
  • <#unsorted2 = "a=10,b=1,c=100,d=5">
Type Description Example/Result
Append Add a new index to the end of a list. <#list:append="d"> b,c,a,d
<#list:sort,append="e"> a,b,c,d,e
Delete Remove an index from a list. <#list:delete="1"> a,c,d,e
<#list:sort,delete="1"> a,d,e
If the value isn't an index it will try deleting it by name. <#list2:split=";",delete="c"> b;a
Works with pair values too. <#pairs:delete="b"> a=3,c=1
Each Parse the value for each of the items in a list (splits by comma by default). Defines <#each> (the whole value), <#eachcount> (increments during the each), <#truecount> (increments during each that was True), <#name> (split left of = or just itself if #name has a value), and <#value> (split right of = if #name has no value). <#"1,2,3,4":each="<li><#each>";ul>
  • 1
  • 2
  • 3
  • 4
Sort first. <#"c;a;b":sort=";",each="<#each>;",chop> a;b;c
Use name and value pairs. <#"a=1,b=2,c=3":each="<#name> & <#value><br>"> a & 1
b & 2
c & 3
EachFalse If used with "test" function this value of an "EachFalse" may be returned for the False evaluations. (To be used with a "test" function and imediately proceeding or following an "each" function.) <#"1,2,3":test="<#name> == 2" each="<li><#name> is True" eachfalse="<li><#name> is FALSE";ul>
  • 1 is FALSE
  • 2 is True
  • 3 is FALSE
Index Split and return the index of the list. <#list2:split=";",index="0"> b
Split, sort, and return the index of the list. <#list2:sort=";",index="0"> a
<#list2:sort=";",index="1"> b
Split, invert, and return the index of the list. <#list2:invert=";",index="0"> a
Index alone splits using commas. (Example is the same as <#list[2]>.) <#list:index="2"> e
Randomize a group of keys and then return the first one. <#list:randomize,index="0"> e
<#list:randomize,index="0"> d
<#list:randomize,index="0"> a
Indexes Returns the amount of indexes of a list. <#tenlist:indexes> 10
Total files in a folder. <#/company/:indexes> 0
Split and return specific indexes of a list. <#tenlist:indexes="0,9"> 1,10
A range of indexes from a list. <#tenlist:indexes="3-6"> 4,5,6,7
Return an amount of indexes from the beginning of a list. <#tenlist:indexes="3"> 1,2,3
Return an amount of indexes starting from the end of a list. <#tenlist:indexes="-3"> 10,9,8
Invert Split and return the values in reverse order (split by comma by default). <#"Aa,Bb,Cc":invert> Cc,Bb,Aa
Use a custom value. <#"Aa;Bb;Cc":invert=";"> Cc;Bb;Aa
Sort then reverse. <#"Bb,Cc,Aa":sort,invert> Cc,Bb,Aa
ListHeaders="" Assign the names and values of a list headers and converts it to tabular data. <#"A=1,B=2":listheaders="Letter,Number",table>
Letter Number
A 1
B 2
Loop Build a value by looping the same thing (each increment is defined in <#each>). <#3:loop="<#each><br>"> 1
2
3
NamesOnly Removes the values from a list. <#pairs:namesonly> a,c
Ordinal Convert a positive integer to a ordinal suffix. <#1:ordinal>, <#13:ordinal> 1st, 13th
Place Returns the placement of a list item or key. Returns 0 if not present. <#"101,102,103":place="102"> 2
Pop Remove (pop off) the last index from the end of a list. <#list:pop> a,d
<#list:sort,pop> a
Prepend Add a new index to the beginning of a list. <#list:prepend="x"> x,a
Sort then prepend. <#list:sort,prepend="y"> y,a,x
Prepend then sort. <#list:prepend="z",sort> a,x,y,z
Random Return one random item. <#list:random> y
Flip a coin. <#"Heads,Tails":random> Heads
Dice roll. <#1,2,3,4,5,6:random> 4
Randomize Randomize the order (split by comma by default). <#list:randomize> a,y,z,x
<#list:randomize> z,x,y,a
<#list:randomize> y,a,x,z
<#list2:randomize=";"> b;a
Shift Remove the first index from the beginning of a list. <#list:shift> y,a,x
<#list:sort,shift> x,y
Sort Split, sort alphabetically, and return the value sorted (split by comma by default) case in-sensitive. <#list:sort> x,y
Use a custom value. <#list2:sort=";"> a;b
Sort pairs. <#pairs:sort> a=3,c=1
SortCase Split, sort alphabetically, and return the value sorted (split by comma by default) case sensitive. <#"b","a","B","A":sortcase> A,B,a,b
SortNum Split, sort numerically, and return the value sorted (split by comma by default). <#unsorted:sortnum> 1,5,5,10,100
Split Split is the separator value for converting a value into a list (comma is the separator by default if ommited or has no value). <#"A;B;C":split=";",indexes>
3
<#"AxBxC":lower,split="x",each="<#each>Y"> aYbYcY
Stack Sort pairs alphabetically by their values (case in-sensitive). <#pairs:stack> c=1,a=3
StackCase Sort pairs alphabetically by their values (case sensitive). <#"4=b","3=a","2=B","1=A":stackcase> 1=A,2=B,3=a,4=b
StackNum Sort pairs numerically by their values. <#unsorted2:stacknum> b=1,d=5,a=10,c=100
SubList Evaluate its condition for each item in a list and return a new list of only the items that returned the condition True (using the each, name, and value within the condition as needed). <#"A,B,C,D":sublist="name eq 'B' || name eq 'C'"> B,C
Test If a "test" is present before "each" or "eachfalse" it will only return the each/eachfalse contents as the test results True or False respectively. <#"1,2,3,4":test="name >= 3" each="<li><#name></li>">
  • 3
  • 4
  • Unique Remove duplicate names. <#dupe:unique> a,b,c
    Pairs inherent last value. <#dupe2:unique> a=1,b=3,c=1
    UniqueCount Audits values in pairs and returns a new paired list of the values and how many times they occured respectively. <#"a=100,b=100,c=50,d=100":uniquecount> 100=3,50=1
    ValuesOnly Removes the names from a list. <#pairs:valuesonly> 3,1