Skip to Main Content
Realm of Racket
book

Realm of Racket

by Conrad Barski M.D., David Van Horn, Eight Students of Northeastern University, Matthias Felleisen
June 2013
Intermediate to advanced content levelIntermediate to advanced
312 pages
6h 47m
English
No Starch Press
Content preview from Realm of Racket

Chapter 2. (A First Racket Program)

#|

You’ve installed DrRacket, learned that programs go into the definitions panel, and experimented with Racket in the interactions panel. You are now ready to write your first real program, a simple game for guessing numbers.

|#

2.1 The Guess My Number Game

The first game we will write is one of the simplest and oldest games around. It’s the classic Guess My Number game. In this game, the player thinks of a number between 1 and 100. Our program will then figure out that number by repeatedly making guesses and asking the player if her number is bigger or smaller than the current guess.

The following piece shows what a game might look like in the interactions panel if the player chose 18:

> (guess) 50 > (smaller) 25 ...
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

Elm in Action

Elm in Action

Richard Feldman
Handbook of Constraint Programming

Handbook of Constraint Programming

Francesca Rossi, Peter van Beek, Toby Walsh

Publisher Resources

ISBN: 9781457185120Errata