# Subtract and intercalate lists

I have a list where the sum of its values results 10:

timeEachStep = {{0.7646050049957724}, {1.1043813977215065}, {1.792518103577381}, {1.5769143982179603}, {2.475716623701331}, {2.2858644717860503}}
Plus @@ timeEachStep


$\left( \begin{array}{c} 0.764605 \\ 1.10438 \\ 1.79252 \\ 1.57691 \\ 2.47572 \\ 2.28586 \\ \end{array} \right)$

${10}$

And I have another value that will change the above list

tClaw = 0.2


$0.2$

With my limited knowledge I had to create a list of work

list2 = Table[tClaw, Length[timeEachStep]]


$\{0.2,0.2,0.2,0.2,0.2,0.2\}$

This list should be added to the other list, but without changing the sum of values. Then I did a subtraction, then I added the values intercalating.

list3 = timeEachStep - list2
Plus @@ list3


$\left( \begin{array}{c} 0.564605 \\ 0.904381 \\ 1.59252 \\ 1.37691 \\ 2.27572 \\ 2.08586 \\ \end{array} \right)$

${8.8}$

newList = Flatten[Transpose[{list3, list2}]]
Plus @@ newList


$\{0.564605,0.2,0.904381,0.2,1.59252,0.2,1.37691,0.2,2.27572,0.2,2.08586,0.2\}$

$10$

There is a specific function that makes this?

• Flatten@Riffle[timeEachStep - tClaw, tClaw, {2, -1, 2}] should do it. Oct 7, 2016 at 13:47
• Yes. It's that simple. Oct 7, 2016 at 14:02
• Flatten@{# - tClaw, tClaw} & /@ timeEachStep Oct 7, 2016 at 16:23

Flatten@Riffle[timeEachStep - tClaw, tClaw, {2, -1, 2}]

$\{0.564605,0.2,0.904381,0.2,1.59252,0.2,1.37691,0.2,2.27572,0.2,2.08586,0.2\}$