This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| pf:prpldocs:lists [2016/06/23 17:20] – created virgilw | pf:prpldocs:lists [2025/02/14 14:57] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 22: | Line 22: | ||
| =CMD | =CMD | ||
| - | =COMMAND | + | =COMMAND |
| =DESC | =DESC | ||
| - | TODO | + | Creates an empty list. |
| =ENDDESC | =ENDDESC | ||
| =EX | =EX | ||
| - | TODO | + | if (CreateList GetListCount eq0) |
| + | Trace(" | ||
| + | endif | ||
| =ENDEX | =ENDEX | ||
| =ENDCMD | =ENDCMD | ||
| + | =CMD | ||
| + | =COMMAND CreateListStartingSize (int) list | ||
| + | =DESC | ||
| + | Creates a list containing a specified number of nulls. | ||
| + | =ENDDESC | ||
| + | =EX | ||
| + | Trace(CreateListStartingSize(7)[6]) #I don't even know what the standard use case of this command is. Someone please write a better example. | ||
| + | =ENDEX | ||
| + | =ENDCMD | ||
| + | |||
| + | =CMD | ||
| + | =COMMAND GetListCount (list) int | ||
| + | =DESC | ||
| + | Returns the number of entries in a list. | ||
| + | =ENDDESC | ||
| + | =EX | ||
| + | Split(" | ||
| + | Trace(GetListCount(< | ||
| + | =ENDEX | ||
| + | =ENDCMD | ||
| + | |||
| + | =CMD | ||
| + | =COMMAND GetListElement (list int) value | ||
| + | =DESC | ||
| + | Returns the value at the specified index of a list. Lists are indexed from zero. | ||
| + | |||
| + | If a list is stored in a variable, this can be abbreviated to < | ||
| + | =ENDDESC | ||
| + | =EX | ||
| + | Split(" | ||
| + | 0 6 do | ||
| + | Trace (<-list I GetListElement) | ||
| + | Trace (< | ||
| + | loop | ||
| + | =ENDEX | ||
| + | =ENDCMD | ||
| + | |||
| + | =CMD | ||
| + | =COMMAND SetListElement (list int value) | ||
| + | =DESC | ||
| + | Stores a value at the specified index of a list. The previously stored value is overwritten. | ||
| + | |||
| + | If a list is stored in a variable, this can be abbreviated to <-value -> | ||
| + | =ENDDESC | ||
| + | =EX | ||
| + | Split(" | ||
| + | SetListElement(< | ||
| + | " | ||
| + | Trace(< | ||
| + | =ENDEX | ||
| + | =ENDCMD | ||
| + | |||
| + | =CMD | ||
| + | =COMMAND InsertListElement (list int value) | ||
| + | =DESC | ||
| + | Stores a value at the specified index of a list. The previously stored value, and all subsequent values have their indices shifted up by one. | ||
| + | =ENDDESC | ||
| + | =EX | ||
| + | Split(" | ||
| + | InsertListElement(< | ||
| + | Trace(< | ||
| + | =ENDEX | ||
| + | =ENDCMD | ||
| + | |||
| + | =CMD | ||
| + | =COMMAND AppendToList (list value) | ||
| + | =DESC | ||
| + | Adds a value to the end of a list. | ||
| + | =ENDDESC | ||
| + | =EX | ||
| + | Split(" | ||
| + | AppendToList( <-list 7) | ||
| + | Trace(< | ||
| + | =ENDEX | ||
| + | =ENDCMD | ||
| + | |||
| + | =CMD | ||
| + | =COMMAND PrependToList (list value) | ||
| + | =DESC | ||
| + | Adds a value to the beginning of a list. Any values previously stored in the list are shifted up by one. | ||
| + | =ENDDESC | ||
| + | =EX | ||
| + | Split(" | ||
| + | PrependToList( <-list 0) | ||
| + | Trace(< | ||
| + | =ENDEX | ||
| + | =ENDCMD | ||
| + | |||
| + | =CMD | ||
| + | =COMMAND AppendStackToList (list) | ||
| + | =DESC | ||
| + | Adds all values on the stack to the end of a list. The order of the values will be reversed. | ||
| + | =ENDDESC | ||
| + | =EX | ||
| + | Split(" | ||
| + | Split(" | ||
| + | Trace(< | ||
| + | =ENDEX | ||
| + | =ENDCMD | ||
| + | |||
| + | =CMD | ||
| + | =COMMAND PrependStackToList (list) | ||
| + | =DESC | ||
| + | Adds all values on the stack to the beginning of a list. Any values previously stored in the list are shifted up. | ||
| + | =ENDDESC | ||
| + | =EX | ||
| + | Split(" | ||
| + | Split(" | ||
| + | Trace(< | ||
| + | =ENDEX | ||
| + | =ENDCMD | ||
| + | |||
| + | =CMD | ||
| + | =COMMAND CopyList (list) list | ||
| + | =DESC | ||
| + | Creates a copy of a list with the same contents. Someone more computer-eloquent explain pass by reference vs. value here. Note that if the list contains other lists, they will not be copied - for that you need DeepCopyList. | ||
| + | =ENDDESC | ||
| + | =EX | ||
| + | Split(" | ||
| + | <-list CopyList ->list2 | ||
| + | SetListElement(< | ||
| + | Trace(< | ||
| + | Trace(< | ||
| + | =ENDEX | ||
| + | =ENDCMD | ||
| + | |||
| + | =CMD | ||
| + | =COMMAND DeepCopyList (list) list | ||
| + | =DESC | ||
| + | Creates a copy of a list with the same contents. Someone more computer-eloquent explain pass by reference vs. value here. If the list contains any other lists, they are also recursively deep copied. | ||
| + | =ENDDESC | ||
| + | =EX | ||
| + | #TODO | ||
| + | =ENDEX | ||
| + | =ENDCMD | ||
| </ | </ | ||
| < | < | ||