Exercise 4.13: Querying the Data with filter
If we think of this CSV data as a database, then writing queries is a question of writing and combining predicates. In this exercise, we will use filter
to narrow our dataset down to the exact information we want. Imagine that the journalists on your team are working on a new project dedicated to famous tennis rivalries. As a first step, they've asked you to produce a list of all the tennis matches won by Roger Federer. Let's get started:
- Make sure that your project is set up the same way as it was in the previous exercises.
- Create a function called
federer-wins
that provides the CSV processing steps we've already used. Add the calls toselect-keys
anddoall
, which will be applied to the data once it has been narrowed down:(defn federer-wins [csv] (with-open [r (io/reader csv)] (->> (csv/read-csv r) ...