List Block
  • 14 Dec 2022
  • 2 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

List Block

  • Dark
    Light
  • PDF

Article summary

It consists of all the operations pertaining to Lists. 


Create List:

This block is used to create a series of list items within a list. It is very similar to the declaration of arrays. 

Input 

Output

Block Layout

Generated Code

Value of any type 

Returns the list of all the input values

Create

[null, null, null]



Length of the List:

 This block is used to identify the length of a particular list. 

Input 

Output

Block Layout

Generated Code

Variable or list value

Returns the length of the list items.

Length

[].length


List Find Value:

It is used to find a particular list item from a list of values. The first or last occurrence of the item within a list is identified in this block. 

Input 

Output

Block Layout

Generated Code

Variable or list value for input-1

 

Choose the type of search 

 

The variable or value to be searched for input-2.

Returns the index of the input-2 occurrence in input-1 based on choice.



list.indexOf('') + 1

list.lastIndexOf('') + 1


List Get Value:

This block is used to fetch a particular value of a list item within the list. This is done using the GET function. Additionally, there is also another option to 'Get and Remove' the list item once fetched. 

The list item can be fetched from the first item, or from the last item, or randomly. 

Input 

Output

Block Layout

Generated Code

Variable or list value for input-1

 

Choose the get or remove type,

 

Choose the get index type,

 

Variable or number for the index input-2.

Get or remove the value of input-2 in the given list input-1 based on choice.



list[0]

list.splice(0, 1)[0]

list.splice(0, 1)


List Set or Insert Value:

Any value can be inserted within a list item of a particular list using this block. Values can be set to the variables of the list item for a Set. 

Input 

Output

Block Layout

Generated Code

Variable or list value for input-1

 

Choose the set type,

 

Choose the set index type,

 

Variable or number for the index input-2,

 

Variable or value to store as input-3.

Store the value to the given input-3 to the list input-1 based on choice and input-2.




Note
When the index type is set to 'last', the insert at type appends a new row or updates an existing row based on primary key of the table variable(in list). 

list[0] = null

list.splice(0, 0, null)


SubList:

This block is used to fetch a sublist from within a list. It is used in a similar pattern to Array Slicing. It specifies a range of values that need to be returned from within the List. 

Input 

Output

Block Layout

Generated Code

Variable or list value for input-1

 

Choose the set index type,

 

Variable or number for the index input-2,

 

Choose the set index type,

 

Variable or number for the index input-3.

Returns the sub list from input-1 based on the choice, from input-2 to input-3.




list.slice(0, 1)


List to Text:

This block is used to convert a list items into a series of texts separated by a delimiter. It splits the list items based on predefined conditions and displays the parameters as output text. 

Input 

Output

Block Layout

Generated Code

Choose the type list print (list from the text - will convert Text to list base on the delimiter, text from the list - convert list to text based on delimiter),

 

Variable or list or text value for input-1,

 

Variable or text delimiter for input-2.

Returns list or text based on choice using given list or text input-1 and delimiter input-2.


''.split(',')

[].join(',')


Empty List Check:

This block is used to check if a particular list is empty. It verifies the length of the list and returns a boolean output. 

Input 

Output

Block Layout

Generated Code

Variable or list value for the input

Returns boolean (true or false) based on the input list length

Isempty

![].length

Was this article helpful?

What's Next
ESC

Eddy AI, facilitating knowledge discovery through conversational intelligence