7. Recursion II: Lazy Sequences
Activity 7.01: Historical, Player-Centric Elo
Solution:
- Set up your project, which should be based on the code written for the last exercises in this chapter.
- The solution follows the pattern established with
take-matches
. Let's start with the parameters. We need to define separate behaviors for matches played by the "focus player" and matches played between other players. The first thing we need is, of course, a way to identify the player, so we'll add aplayer-slug
argument. This wasn't necessary intake-matches
because there we treated all the matches the same, regardless of who played in them.In
take-matches
, we had alimit
argument to control how deeply we walked the tree. In this case, we need two different parameters, which we will callfocus-depth
andopponent-depth
. Together, that gives us the following parameters for our newfocus-history
function:(defn focus-history [tree player-slug focus-depth opponent...