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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access