appendList ( list, item ) |
Returns: list | Location: Built-in | ||||||
Appends item to the end of list and returns the resulting list. Example: my_list = [1 2 3]; printList(appendList(my_list, 4)); >> [1 2 3 4] |
assocAt ( list, name ) |
Returns: anything | Location: Built-in | ||||||
Given an associative list in list, this function will return the value associated with the name parameter. If the name does not exist in the list, null will be returned. Example: assoc_list = [["a" "b" "c"] [1 2 3]]; print assocAt(assoc_list, "a"); >> 1 See Also: |
assocPut ( list, name, value ) |
Returns: list | Location: Built-in | ||||||||
Given an associative list in list, this function will add a new name/value pair to the list as specified in name and value. The name and value can be of any type (integer, string, etc.). If there is already an item in the list with the same name, it's associated value will be replaced with value. Examples:
See Also: |
assocTake ( list, name ) |
Returns: anything | Location: Built-in | ||||||
Given an associative list in list, this function will return the value associated with the name parameter. If the name does not exist in the list, null will be returned. After retreiving the value, the name/value pair is removed from the associative list. Examples:
See Also: |
deepCopy ( list ) |
Returns: list | Location: Built-in | ||||
Returns an exact copy of the list passed in list, including any number of sub-lists. Since most list operations take place on the actual list rather than with a copy of it (as described in the Lists documentation), this function allows you to make an actual copy of a list and manipulate the copy without affecting the original. Compare examples one and two to see the differences between using deepCopy() or using a regular assignment statement. If you are unclear on why lists work in the manner they do, be sure to read the documentation describing lists. Examples: |
first ( list [, item-count ]) |
Returns: list | Location: Built-in | ||||||
Returns the first item of the list, or the first item-count items, if that parameter is defined. If item-count is larger than the number of items in the list, the whole list will be returned. If the list is empty, the returned value will be null. Examples:
See Also: |
indexOf ( list, value [, sublist-index ]) |
Returns: integer | Location: Built-in | ||||||||
Returns the numerical index of the first item in list equal to value. If there is not a matching item in the list, zero will be returned. The optional parameter sublist-index allows you to perform a search on a list of sub-lists. Each sub-list will be compared to value using the item at position sublist-index. Examples:
|
indexOfSorted ( list, value ) |
Returns: integer | Location: Built-in | ||||||
Returns the numerical index of the first item in list equal to value. If there is not a matching item in the list, zero will be returned. This function works exactly the same as indexOf, except that list is assumed to be sorted in ascending order. This allows the list to be searched more efficiently, dramatically improving search times for large lists. The companion function insertPosition can be used to keep the list sorted when adding items. Examples:
See Also: |
insertAt ( list, index, value ) |
Returns: list | Location: Built-in | ||||||||
Inserts the item given in value into a list, at the location specified by index. If index is greater than the number of items in the list, value will be added to the end of the list. Examples:
|
insertPosition ( list, value ) |
Returns: integer | Location: Built-in | ||||||
Returns the position within list that value should be inserted at in order to keep the list sorted. The item is not inserted in the list; you must call insertAt to do this. This function is intended to be used along with indexOfSorted to greatly improve search times for large lists. Examples:
See Also: |
isAtomic ( list ) |
Returns: boolean | Location: Built-in | ||||
Returns a boolean indicating whether or not list contains any sub-lists. If list is not already a list, it will be coerced into one prior to evaluation. Examples:
See Also: |
isList ( item ) |
Returns: boolean | Location: Built-in | ||||
Returns a boolean indicating whether or not item is a valid list. Examples:
|
itemAt ( list, index ) |
Returns: anything | Location: Built-in | ||||||
Returns the item in list at the index specified in index. Example: my_list = ["a" "b" "c" "d" "e"]; print itemAt(my_list, 4); >> d |
last ( list [, item-count ]) |
Returns: list | Location: Built-in | ||||||
Returns the last item of the list, or the last item-count items, if that parameter is defined. If item-count is larger than the number of items in the list, the whole list will be returned. If the list is empty, the returned value will be null. Examples:
See Also: |
listDepth ( list ) |
Returns: integer | Location: Built-in | ||||
Returns the maximum number of sub-lists contained within list. If the list is atomic, 1 will be returned. Examples:
See Also: |
max ( list ) |
Returns: anything | Location: Built-in | ||||
Returns the largest item in list. A list of strings will return the last string alphabetically. If the list is empty, null will be returned. Examples:
See Also: |
mid ( list, index [, item-count ]) |
Returns: list | Location: Built-in | ||||||||
Returns the item of the list at position index. If item-count is defined, that many items will be returned beginning at index. If index is less than one, list position 1 will be used. If index is greater than the total number of items in the list, the last item position will be used. If item-count exceeds the number of items in the list, all values following index will be returned. If the list is empty, the returned value will be null. Examples:
See Also: |
min ( list ) |
Returns: anything | Location: Built-in | ||||
Returns the smallest item in list. A list of strings will return the first string alphabetically. If the list is empty, null will be returned. Examples:
See Also: |
printList ( list ) |
Returns: null | Location: ListUtils.lib | ||||
Given any list specified by list, this function will print the list in standard SiphonScript format. Very helpful when debugging templates or printing the contents of a list to WebSiphon's log window using appendLog(). If the passed value is not a list, it will be printed as a single item of its own type. Examples:
See Also: |
printListOutline ( list ) |
Returns: null | Location: ListUtils.lib | ||||
Given any list specified by list, this function will print the list as an outline using standard HTML outlining tags. Coupled with some of the functions in the File functions, this function could be used to generate a dynamic site outline. If the passed value is not a list, it will be printed as a single item of its own type. Example: my_list = ["Heading One" ["Item One" "Item Two"] "Heading Two"]; printListOutline(my_list);>> |
remove ( list, value ) |
Returns: list | Location: Built-in | ||||||
Removes all occurrences of value from a list. If there are no occurences of value in the list it will not be altered. An attempt to coerce value to each list item's type will be performed during the removal process, so passing the string "4" will remove any integer or float list items whose value is 4 as well as any matching strings. Examples:
See Also: |
removeAt ( list, index ) |
Returns: list | Location: Built-in | ||||||
Removes the item at position index from a list. The list will not be altered if index is out of range. This function preserves the order of items in a list, so using it on a large list will be slower than removeAtFast(). If preserving list order is not necessary, use removeAtFast() for optimal speed. Examples:
See Also: |
removeAtFast ( list, index ) |
Returns: list | Location: Built-in | ||||||
Removes the item at position index from a list. The list will not be altered if index is out of range. The last item of the list will be moved to index rather than moving around many list items. As a result, this function is must faster than removeAt() but does not maintain list order. If preserving list order is important, use removeAt() instead. Examples:
See Also: |
sizeOf ( list ) |
Returns: integer | Location: Built-in | ||||
Returns the number of items contained in list. Examples:
|
sort ( list [, descending, sublist-index ]) |
Returns: list | Location: Built-in | ||||||||
Returns the list passed to it, sorted in either ascending or descending order. If the descending parameter is not present or evaluates to false, list will be sorted in ascending order. The optional parameter sublist-index allows you to perform sorting on a list of sub-lists. Each sub-list will be sorted as a single item based on the value of the item at the index specified in sublist-index. The third example below demonstrates this functionality. Examples:
|
takeAt ( list, index ) |
Returns: anything | Location: Built-in | ||||||
Returns the item in list at the index specified in index, then removes that item from the list. Examples: |