Lists
Last updated
Last updated
Lists are a fundamental data structure used to store multiple pieces of information in a single variable. Think of a list as a container that holds a collection of items arranged in a specific order. Each item within the list is assigned an index, which allows you to access and manipulate individual elements. The blocks in this section allows you to create lists, manipulate them, and retrieve items from them.
create empty list
Creates an empty list.
create list with
Creates a list with any number of items.
create list with item repeated times
Creates a list with the same item repeated a given number of times.
length of
Returns the length of a given list.
is empty
Returns whether the given list is empty or not.
add item to list
Adds an item to the end of the list.
In list find first occurrence of item
Returns the position of the first occurrence of the item in the list. The index starts from 1. Returns 0 if not found.
Key points:
The function iterates through the list in order to find the first occurrence.
It can handle lists containing elements of any data type.
In list find last occurrence of item
Returns the position of the last occurrence of the item in the list. The index starts from 1. Returns 0 if not found.
Key points:
The function iterates through the list in reverse order to find the last occurrence.
It can handle lists containing elements of any data type.
Can’t find it? You need to click the “first” to get the dropdown menu and then choose last.
In list get/get and remove/remove #/#from end/first/last/random
This legend shows the block of getting a particular element at the specified location of a list. #1 is the first item.
Key points:
The index parameter is 1-based, meaning the first element is at index 1, the second at index 2, and so on.
Return value undefined when the index is smaller than 1.
Return value undefined when the index is larger than the length of the list.
This block can be extended in multiple ways. In addition to “get”, you can choose “get and remove”, or “remove”.
get and remove: Returns a particular element at the specified location of a list and removes the element in the list.
remove: Removes a particular element at the specified location of a list.
The position of the element can be specified by multiple ways:
# from end: The index from the end. #1 is the last element.
first: the index of the first element, essentially #1.
last: the index of the last element, essentially #length.
random: a random position in the list.
In list set/insert at and remove/remove #/#from end/first/last/random as
This function sets a particular element at the specified location of a list to the given value. #1 is the first item.
Key points:
These functions provide flexibility for modifying lists.
The index parameter is 1-based, meaning the first element is at index 1, the second at index 2, and so on.
There is no change of the list when the index is smaller than 1.
There is no change of the list when the index is larger than the length of the list.
This block can be extended in multiple ways. In addition to “set”, you can choose “insert at”.
insert at: Insert the given item at the specified position in a list. #1 is the first item.
The position of the element can be specified by multiple ways:
# from end: The index from the end. #1 is the last element.
first: the index of the first element, essentially #1.
last: the index of the last element, essentially #length.
random: a random position in the list.
In list get sub-list from #/from end/first to #/from end/last
Returns a new sub-list, which is a copy of the specified portion of the list specified by start and end locations. The start and end location are included.
Key points:
The function does not modify the original list; it creates a new sub-list.
The index must be valid (between 1 and length of the list, inclusive). Otherwise the return value is undefined.
The from and to location can be specified in other ways:
# from end: The index from the end. #1 is the last element.
first: the index of the first element, essentially #1. Can only be used as from location.
last: the index of the last element, essentially #length. Can only be used as to location.
make list from text/text from list with delimiter “”
Split the given text into a list of texts, breaking at each delimiter. Return the list of texts.
Key points:
The delimiter can be any character or text, such as a comma (,), space ( ), semicolon (;), or pipe (|), “abc”.
If the delimiter is an empty text, the given text will be broken character by character.
You can choose “text from list” in the dropdown list. The “text from list” block combines the list of texts with the given delimiter. The returned value is a text.
sort numeric/alphabetic/alphabetic, ignore case ascending/descending
This block sorts a list of numbers in ascending order.
Key points:
The functions use different sorting algorithms depending on the data type (numeric, alphabetic, or alphabetic and ignore case) and the desired order.
For numeric sorting, the natural ordering of numbers is used.
For alphabetic sorting, the lexicographical order (dictionary order) is used, with optional case-insensitive comparison.
You can choose to sort more than numeric type, depending on the item type of the list.
alphabetic: sort in lexicographical order. Only applied to text.
alphabetic, ignore case: sort in lexicographical order, case insensitive. Only applied to text.
In addition to ascending order, you can also choose descending order.