4.6 Reversing a copy of a list
Some algorithms produce results in a reversed order. It’s common to collect the output in a list and then reverse the list. As an example, we’ll look at the way numbers converted into a specific base are often generated from least-significant to most-significant digit. We generally want to display the values with the most-significant digit first. This leads to a need to reverse the sequence of digits in a list.
4.6.1 Getting ready
Let’s say we’re doing a conversion among number bases. We’ll look at how a number is represented in a base, and how we can compute that representation from a number.
Any value, v, can be defined as a polynomial function of the various digits, dn, in a given base, b. A four-digit number would have ⟨d3,d2,d1,d0⟩ as the sequence of digits.
Note that the order we’re using here is reversed from the usual order of items...