How do you manually create "all but first of list" and "reduce list" functionality using basic blocks?

I’m exploring how some of the built-in list blocks work under the hood and would love to understand how to recreate their logic manually.

Specifically, I'm trying to replicate:

1."All but first of list"
lists_but_first(1)
– returns a list with all items except the first one.
2. "Reduce list starting with initial value by combining item and answer so far"
lists_reduce(1)
– like a reduce/fold function, where each list item is combined using a custom procedure and an initial value.

I’m doing this for learning purposes and to get a better grasp of how to build similar functionality with basic blocks (like loops and procedures). If anyone can share how these can be implemented step-by-step or with example blocks, that would be greatly appreciated!

for all but first of list, it's easy. just remove item 1 of list.

for reduce list function, it's not easy to make a general / universal procedure (only use build-in blocks), since AI2 do not support anonymous procedure.

1 Like

i tried all but first of list- succeeded
but reduce list - trying

Or probably you are doing this, because you have a Kodular project and the reduce list block is not available there?

Probably you now realize, that it would be a good idea to ask only in the community of the builder you are using?

Why don't you use one of the othe solutions you already received here

instead of wasting orher people's time?
Taifun

Nope... he is not me. I don't use Kodular.

In this case I apologize, but the last part of my answer is still valid

Why don't you use one of the other solutions you already received here

Taifun

The other solutions also involve reducing the list. I'm still trying to stick with the procedure. In the end, I may learn and share the correct approach.

Make sure you copy the input list before removing item 1 from the non-empty copy.

Otherwise, you will decapitate the original list, an unwanted side effect.

I finally made an extension for my purpose. I've been sitting in front of my computer since then trying to solve this problem. I'm finally going to sleep now. :sweat_smile: I also used a small procedure.
ListColumnReducer.aix (8.0 KB)