How to make a complex list to simple

I’ve tried but didn’t worked, I am not able to make a logic.

I have two list in each list and in each item of list there are items separated by slash

List1:-
Mango/banana
Lichi
Banana/Lichi/mango

List2 is having numbers:-
1/2
4
2/3/2

I want that suppose for first item of list in list1 is mango/banana and in list2 is 1/2 . In same index if we check then mango and banana are having value 1 and 2 respectively and so on if further there are. The numbers are showing the quantity. I want that some through the kodular blocks, it give me result like this for this item of list
Mango/banana/banana

Here banana is twice because it’s value was 2
I want this to be with every item of list

Now for full result output should be like this:
Mango/banana/banana
Lichi/Lichi/Lichi/Lichi
banana/banana/Lichi/Lichi/Lichi/Mango/Mango

What I’ve did since now:
I’ve used for each item block then for every item in the list, I’m spliting it by /
Then the length of that splitted , I used snackbar to notify my self if I am write or wrong but later whatever I did was totally illogical ig that’s why it was giving me somekind of error. I was making my logic but failed.

1 Like

Hi Karanvir,

This is a possible solution with 2 procedures,

formatList

This one to format your lists

In a list of list

((Mango banana) (Lichi) (Banana Lichi mango))

repeatItemBasedOnNumber

This part to cycle through list

Filter.aia (4.7 KB)
(Filter.aia because I was helping another person and got confused with the project names )

2 Likes

Thnks, it’s actually working

But I didn’t understand the logic after u attached for each number2 block

I’m glad you asked,
Since you want to learn without just copying and pasting, love you :heart_hands:

We have 2 List of List

listOfItems 
((Mango banana) (Lichi) (Banana Lichi mango))

and

listOfNumbers 
((1 2) (4) (2 3 4))

the first for each number1 we cycle through listOfItems
1 cycle (Mango banana)
2 cycle (Lichi)
3 cycle (Banana Lichi mango)

for each number2 cycle through the first cycle (Mango banana)
and we get
1 cycle Mango
2 cycle banana

number1 and number2 will be our indexes to point the listOfNumbers

number1 = 3
`listOfItems` = (Banana Lichi mango)
`listOfNumbers` = (2 3 4)

number2 = 2
`listOfItems` = Lichi
`listOfNumbers` = 3

Then we use repeatItemBasedOnNumber item = Lichi | number = 3
and we get

Lichi/Lichi/Lichi

I hope I was clear enough
If you still need anything, I’m here :heart_hands:
Happy :kodular:oding

1 Like

That was detailed and I got the logic
Thnks so much

2 Likes

Perfect, good work dear

2 Likes