Skip to Main Content
Programming Clojure, 3rd Edition
book

Programming Clojure, 3rd Edition

by Alex Miller, Stuart Halloway, Aaron Bedra
February 2018
Intermediate to advanced content levelIntermediate to advanced
304 pages
7h 11m
English
Pragmatic Bookshelf
Content preview from Programming Clojure, 3rd Edition

Interactive Play

As you consider interactive play, you’ll need to make a few additions to the program. Right now the game only returns the final score, but an interactive game should report progress as the game progresses. Also, right now you’re choosing the word to guess, but we really need to let the program choose a random word so it’s a mystery to a human player.

Let’s tackle the random word first. Included in the hangman project is a file words.txt, which contains about 4000 words that you can use as a word bank. First, read those words into a data structure.

 (​defn​ valid-letter? [c]
  (<= (int ​\a​) (int c) (int ​\z​)))
 
 (defonce available-words
  (with-open [r (jio/reader ​"words.txt"​)]
  (->> (line-seq ...
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.
Start your free trial

You might also like

Programming Kotlin

Programming Kotlin

Venkat Subramaniam
Getting Clojure

Getting Clojure

Russ Olsen

Publisher Resources

ISBN: 9781680505719Errata Page