List
A list type is an object that can hold a list of other types. When you drag a list onto the canvas, you can populate it with a list of other types.
With a list type you can, for example, make a list of strings, a list of dates, a list of Types or of any other type Linx caters for.
Properties
Type
Select the List element type, e.g. String, Bolean, Integer, List, etc
Value
The default value for the variable. This value can contain either json or xml.
List functions
Functions that can be performed on
All
Goes through the List and tests each element against a specific condition. If all of the items in the List satisfies the condition, then returns 'true'. If any item goes against the condition, then returns 'false'.
Returns: Boolean.
Example:
Any
Determines whether a sequence contains any elements.
Syntax:
Examples:
Append
Returns a sequence that starts with the given sequence followed by the specified value.
Syntax:
Example:
Average
Computes the average of a sequence of numeric values.
Syntax:
Examples:
Concat
Joins 2 lists together by adding the second list to the end of the first list. The List types must be the same.
Returns: List. List will be of the same type as the original two, containing all the elements.
Example:
Contains
Check whether an item exists inside of the list.
Returns: Boolean - 'true' if List contains the item, 'false' if List does not contain item.
Example:
Count
Returns the number of elements in a sequence.
Syntax:
Examples:
ElementAt
Fetch an element at a specific index in the List. Important note, Lists in Linx are zero-indexed, which means the first element in the list is at index 0.
Returns: Generic. Will return the same type that the List is set as. If a List type is String, then ElementAt returns String, if List is a defined Type Person, then ElementAt returns a Person.
Example:
[] (Square Brackets)
Fetch an element at a specific index in the List. Important note, Lists in Linx are zero-indexed, which means the first element in the list is at index 0.
Returns: Generic. Will return the same type that the List is set as. If a List type is String, then [] returns String, if List is a defined Type Person, then [] returns a Person.
Example:
ElementAtOrDefault
Fetch an element at a specific index in the List, however if the index is out of the List’s range, then returns a default (which is <NULL> in most cases) without raising an exception.
Important note: Lists in Linx are zero-indexed, which means the first element in the list is at index 0.
Returns: Generic. Will return the same type that the List is set as. If a List type is String, then ElementAt returns String, if List is a defined Type Person, then ElementAt returns a Person.
If the index is out of the List’s range, return’s a <NULL>
Example:
First
Fetch the first element in a List.
Returns: Generic. Will return the same type that the List is set as. If a List type is String, then First returns String, if List is a defined Type Person, then First returns a Person.
Example:
FirstOrDefault
Fetch the first element in a List. However, if the List is empty, returns a <NULL> instead of raising an exception.
Returns: Generic. Will return the same type that the List is set as. If a List type is String, then FirstOrDefault returns String, if List is a defined Type Person, then FirstOrDefault returns a Person. If the List is empty, return’s a <NULL>
Example:
Last
Fetch the last element in a List.
Returns: Generic. Will return the same type that the List is set as. If a List type is String, then Last returns String, if List is a defined Type Person, then Last returns a Person.
Example:
LastOrDefault
Fetch the last element in a List. However, if the List is empty, returns a <NULL> instead of raising an exception.
Returns: Generic. Will return the same type that the List is set as. If a List type is String, then LastOrDefault returns String, if List is a defined Type Person, then LastOrDefault returns a Person. If the List is empty, return’s a <NULL>
Example:
Max
Returns the maximum value in a sequence of values.
Syntax:
Examples:
Min
Returns the minimum value in a sequence of values.
Syntax:
Examples:
OrderBy
Order a List using a specific property within the List in ascending order. For Simple types, like String, and Integer, you will still need to define the property to order by. For complex types, for instance, Person, you need to provide the property to order by, for example Name.
Returns: List<Generic>. Will return a List of the same type as the original. For instance if the original List was a List of Strings, then OrderBy returns a List<String>.
Example:
OrderByDescending
Order a List using a specific property within the List in descending order. For Simple types, like String, and Integer, you will still need to define the property to order by. For complex types, for instance, Person, you need to provide the property to order by, for example Name.
Returns: List<Generic>. Will return a List of the same type as the original. For instance if the original List was a List of Strings, then OrderBy returns a List<String>.
Example:
Single
Provides the only item in a List. If a list contains no items or more than one, an exception is thrown.
Returns: Generic. Will return the same type that the List is set as. If a List type is String, then Single returns String, if List is a defined Type Person, then Single returns a Person.
Example:
SingleOrDefault
Provides the only item in a List. Returns
Returns: Generic. Will return the same type that the List is set as. If a List type is String, then Single returns String, if List is a defined Type Person, then Single returns a Person.
Example:
Skip
Provides a List where the first number of items are removed. You provide a number of items to skip.
Returns: List<Generic>. Will return a List of the same type as the original. For instance if the original List was a List of Strings, then Skip returns a List<String>.
Example:
SkipWhile
Provides a sequence that discards items as long as a specified condition is 'true' and then returns the remaining items.
Returns: List<Generic>. Will return a List of the same type as the original. For instance if the original List was a List of Strings, then SkipWhile returns a List<String>.
Example:
Take
Provides a List of only the first number of items. You provide a number of items to take.
Returns: List<Generic>. Will return a List of the same type as the original. For instance if the original List was a List of Strings, then Take returns a List<String>.
Example:
TakeWhile
Provides a sequence that relays items as long as a specified condition is 'true' and then discards the remaining items.
Returns: List<Generic>. Will return a List of the same type as the original. For instance if the original List was a List of Strings, then TakeWhile returns a List<String>.
Example:
Where
Goes through the List and tests each element against a specific condition, and only taking the elements which satisfies the condition.
Returns: List<Generic>. Will return a List of the same type as the original. For instance if the original List was a List of Strings, then TakeWhile returns a List<String>.
Example:
Links
Use the AddToList function to append values to your list dynamically.
Use the ClearList function to remove all values from a list.