Question: how to generalize this inserting values method into a general procedure function?

sourcesamples := [evalf(-1-sqrt(7)), -2, 1, evalf(-1 + sqrt(7)), 2];
templatesamples := [A, evalf(-1-sqrt(7)), A, -2, A, 1, A, evalf(-1 + sqrt(7)), A, 2, A];
samples := [-4, evalf(-1-sqrt(7)), -3, -2, 0, 1, evalf(3/2), evalf(-1 + sqrt(7)), evalf(9/5), 2, 3]

want to insert value alternatively according to the template and neighbor values

 

Some inserted values come from

floor(evalf(-1-sqrt(7)))
ceil(evalf(-1-sqrt(7)))

(round(evalf(-1+sqrt(7)),0) + 1)/2;
(2 + 1)/2
=evalf(3/2)

(round(evalf(-1+sqrt(7)),1) + 2)/2;
(1.6 + 2)/2
=evalf(9/5);

how to generalize this method into general case function instead of manual inesrt?

Please Wait...