Explanation

The code in Listing 6: