I have the following question concerning a list algorithm in GAP:
Let $L_1$ be a non-empty list with certain objects as entries.
I wrote a program and called it helping_program_1.
The Input for helping_program_1 is a list with two entries: $[x,y]$. The first entry $x$ is a list (for example $x=L_1$) and the second entry $y$ is an object.
The Output of helping_program_1 is a list with two entries: $[a,b]$. $a$ and $b$ are lists here. The lengths of $a$ and $b$ are smaller than the length of $x$.
In the next step I want to apply my helping_program_1 to $[a,b[i]]$ for all $i$ in the list $b$.
This gives me
$$[\text{helping_program_1}([a,b[1]]]), \text{helping_program_1}([a,b[2]]]), \text{helping_program_1}([a,b[3]]]), ..., \text{helping_program_1}([a,b[Size(b)]]])]=[[c,d_1], [c,d_2], [c,d_3], ..., [c,d_{Size(b)}]]$$.
Then apply helping_program_1 to $[c,d_1[1]], \text{to}\ [c,d_1[2]], ..., \text{to}\ [c,d_1[\text{Size}(d_1)]], \text{to}\ [c,d_2[1]], \text{to}\ [c,d_2[2]], ..., \text{to}\ [c,d_3[1]], ..., $ and so on.
Now, I would like to repeat this process until one step before the innermost lists are empty and I'd like to get returned all the list elements in the innermost lists with one element, i.e. the elements that "survived" (but might have been transformed) until the penultimate step.
Now, my question is:
Is there a method in GAP that can be applied to this problem (a clever loop maybe(?)), such that GAP applies helping_program_1 in an appropriate way?
I would be thankful for any hints!