I, too, can't see the problem you have.
You demand a function which should calculate vector(s) of pieces of unittubes for varius pipe sections.
Lets clarify input and output of that function.
INPUT: We sure need a minimum of three input values
- Length of the current (last) section; thinks thats z in your flowchart
- Length of unit pipe (Lu)
- Some information about what happened before. This could be
- the last value from the vector of the section before
- the total length of all sections before
- the section length of every section before (which is the most natural approach in my opinion and is what Alan and Fred had chosen)
- the whole vector of vectors of unitparts calculated so far (which looks like you try to do in your sheet)
OUTPUT: what should it be?
- a vector of vectors showing the segmentation of all the sections so far (which your sheet seems to indicate and what Alan and Fred have shown you how to do)
- just the vector of unit segments of the last section
Anyway I think you already got the solution for your problem from both Alan and Fred.
If you know just the length of LC1 and LC2 so just call their function with a vector as parameter consisting of LC1 and LC2 only. Then go ahead with your calculations and eventually you will arrive at LC3. Then call their function again with a vector (LC1,LC2,LC3) as parameter, etc.