Quoted from another thread.
For the Stem and Leaf plot I was thinking of changing the interval in lots of 5, but wlll leave that for another day.
0 | 2 3
0* | 4 7
1 | 5
1* | 2
Dividing stems between lots of 5 (and only 5) is not the most difficult feature to implement in the existing stemplot routine.
However, and you might have done so by accident, the way you presented the example as per your quote, is headache-worthy

I do hope you meant to write:
0 | 2 3 4
0* | 7
1 | 2
1* | 5
Because that actually splits up the lower five leaves 0..4 and upper five leaves 5..9 into two separate stems.
In case that solution is not what you had in mind, then please do mention it and try to explain in more detail how you want to split things up exactly because in that case I have no idea whatsoever (hence headache-worthy

).
Now, let's take a look at the current implementation:
procedure StemAndLeafPlot(numbers: TCardinalList);
var
number, stem, stemMin, stemMax: cardinal;
str: string;
begin
numbers.Sort;
stemMin := numbers.First Div 10;
stemMax := numbers.Last Div 10;
for stem := stemMin to stemMax do
begin
Str := Format('%3d | ', [stem]);
for number in numbers do
begin
if number < 10 * stem
then Continue;
if number >= 10 * (stem + 1)
then Break;
Str := Str + Format('%d ', [number mod 10]);
end;
Writeln(Str);
end;
end;
Because the goal is to split the leaves into a upper and lower half it becomes immediate evident that we do not actually have a leaf variable (as it was not necessary).
It isn't actually necessary to have such a separate variable (we can still use number mod 10) but it will make things easier to read/understand later on.
So, let's start with adding and using the variable leaf that holds the current leaf and while we are at it let's rename the variable Str to stemLeaves (as the string represents the leaves belonging to a certain stem).
procedure StemAndLeafPlot(numbers: TCardinalList);
var
number, stem, leaf, stemMin, stemMax: cardinal;
stemLeaves: string;
begin
numbers.Sort;
stemMin := numbers.First Div 10;
stemMax := numbers.Last Div 10;
for stem := stemMin to stemMax do
begin
stemLeaves := Format('%3d | ', [stem]);
for number in numbers do
begin
if number < 10 * stem
then Continue;
if number >= 10 * (stem + 1)
then Break;
leaf := number mod 10;
stemLeaves := stemLeaves + Format('%d ', [leaf]);
end;
Writeln(stemLeaves);
end;
end;
Now it becomes more evident that whenever it is required to split up the leaf into separate parts that it is possible to check the value of the leaf and in case the leaf number fits into a certain range (let's say 0..4, which represent the lower half) that it can be checked against such range and only add those leaves to stemLeaves variable when the value of the leaf fits into/belong to that range.
You can easily verify that with the above code by replacing
stemLeaves := stemLeaves + Format('%d ', [leaf]);
with
if leaf < 5 then stemLeaves := stemLeaves + Format('%d ', [leaf]);
We can see that this works as expected and the same can be verified for choosing the upper half:
if leaf > 4 then stemLeaves := stemLeaves + Format('%d ', [leaf]);
However, currently the routine does not have any proficiency for keeping track of two separate halves (and we need that in order to be able to printout two separate halves) thus we need to accommodate for that:
procedure StemAndLeafPlot(numbers: TCardinalList);
var
number, stem, leaf, stemMin, stemMax: cardinal;
loStemLeaves, hiStemLeaves: string;
begin
numbers.Sort;
stemMin := numbers.First Div 10;
stemMax := numbers.Last Div 10;
for stem := stemMin to stemMax do
begin
loStemLeaves := Format('%3d.0 | ', [stem]);
hiStemLeaves := Format('%3d.5 | ', [stem]);
for number in numbers do
begin
if number < 10 * stem
then Continue;
if number >= 10 * (stem + 1)
then Break;
leaf := number mod 10;
if leaf < 5
then loStemLeaves := loStemLeaves + Format('%d ', [leaf])
else hiStemLeaves := hiStemLeaves + Format('%d ', [leaf]);
end;
Writeln(loStemLeaves);
Writeln(hiStemLeaves);
end;
end;
Thus we added another string to keep track of the stem and it's leaves and renamed the other one: loStemLeaves and hiStemLeaves.
Then for both these strings we added the initialization (note the additional ".0" and ".5 which were added to the initialization string. You can change that to whatever floats your boat).
Then we added the check for upper and lower half of the leaves and added the current leaf to the corresponding stemLeave string.
The last step requires us to write out both loStemLeaves and hiStemLeaves strings (in that particular order, though you could do it in reverse in case that makes sense for you) to match the required/wanted output.
Of course you can add an additional check whether or not you want the routine to behave in the old implemented or new implemented way so that you can choose the behaviour for the StemAndLeafPlot routine. I leave that up for/to you to implement

Also note that whatever approach I took to come up with a solution for your question that /it is not the only way/ to approach/implement this.
Attached is the complete updated Free Pascal console test project.
Does that fulfill your requirements ?