How to store multiple lists in a single list variable?

I want to store multiple lists in a single list variable and give a name for each list…Just like arraylist in Java.
Example: I have 2 variables: In the first list I have stored only numbers 1, 2, 3, 4, 5, etc. and in the second list I have letters in it: A, B, C, D.
Now I want to store both of the lists in one variable and I want to name the column as “Numbers” for numbers list and “Letters” for letters list…Is this possible?

initialize global arrayList to create empty list;

set global arrayList to make a list (numberList, letterList);
2 Likes

Oh that was easy! Btw how can I store values into “numberList” or “letterList” ?

Oh numberList and letterList are just the two lists you mentioned ((1,2,3,…), (A,B,C,…)).

1 Like

Yes but that is what I don’t want. I want to store both of the lists in only one variable and make 2 columns in it…One for numbers and second for letters :slight_smile:

I don’t get what the problem is. Variable arrayList will indeed have both your lists, numbers in index 1 and letters in index 2.

Ok now I will ask you directly. I have data stored in airtable and there are 10 columns. Let’s say there are 5 items in each column. Now to load the data I will need to declare 10 list variables for each column data. So I don’t want to do that…I want to use only 1 list variable and store all 10 columns data in each different column in the list. Just like creating list array in java, we declare only 1 variable and create elements in it and name them to store multiple lists in one variable. I want to do the same here…

Yes, you can do that. Like an idea you can make a list of lists, putting a category field like this:

Sin%20t%C3%ADtulo-1

Then, you can do foreach loops to divide this list when you want.

Surely there are better ways to do this, but it’s just a quick idea.

2 Likes

If you are trying to merge two lists then use append list block available in list category.

1 Like

Thank you for replying. Now how can I store another number under “1” column name or another letter under “A”?

No I just want to store multiple lists in a single list variable by giving names for each list in a list. I know it sounds weird for Kodular but it is similar to array which we create in Java to store multiple values in a single variable, instead of declaring separate variables for each value. :slightly_smiling_face:

I don’t know why was it so hard to understand from Kanishka’s response.


Perhaps because of he did not represented his example by blocks and the values in the list might look one String.

I know it was rude, sorry.

2 Likes

I have created my own example of how to manipulate these types of lists:

demo.aia (4.2 KB)

Feel free to use it however you want.
As always, it is an example code. It can always be improved.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.