Representing Progress

The word the player is guessing is a string, made up of characters. Two of the most important kinds of data structures we deal with in Clojure are maps (keyed by an index) and sequences (which rely on sequential traversal). We have a number of choices for representing the progress in the game, but choosing between an indexed or sequential view is the critical decision.

So let’s think, at least at a high level, about the operations that use this data structure in the code. The update-progress function seems like the one we care about the most. Given the word and the guessed letter, you need to check whether each letter in the word matches the guess, and if so, update the progress, which keeps track of all letters guessed ...

Get Programming Clojure, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.