Suppose I have a list that looks like the following (Town names and total distance to that town)
resupply = {
{"Coleman", 0},
{"Highwood House", 106},
{"Canmore", 229},
{"Exshaw", 245},
{"Ghost Station", 288},
{"MountainAire", 370},
{"Nordegg", 552},
{"Robb", 672},
{"Hinton", 720}
}
How would I process that list to give me something like
Coleman - Highwood House 106 km
Highwood House - Canmore 123 km
Canmore - Exshaw 16 km
and so on.
The output gives me the two towns being travelled between, and the distance between them.


Table...Table[ fun[ resupply[[i]], resupply[[i+1]] ], {i, 1, Length[resupply]-1}].Partitionis of course better. My point is that it is usually possible to construct a reasonable solution using only a small, core part of the language. – Szabolcs 19 hours agoMapThread[fun, {Most[resupply], Rest[resupply]}]?fun[{name1_, dist1_}, {name2_, dist2_}] := name1 <> " - " <> name2 <> " " <> ToString[dist2 - dist1]There are countless ways – Szabolcs 19 hours ago