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 9. (The Values of Loops)

#|

Lists are a central data type in Racket. We started off manipulating them manually. Then we learned about lambda and functions like map and foldl. Now we will introduce a third and even more powerful way of managing lists: for loops.

|#

9.1 FOR Loops

If you have taken a run-of-the-mill course on programming or read one of those standard introductory books, you know about for loops. Racketeers have a special relationship with loops, and therefore Racket has many kinds of for loops. Each has its own uses and purposes. Anything you can do with map, foldl, foldr, filter, andmap, ormap, and so on, you can do with for loops.

The basic for loop looks and acts like the one you may already know:

> (for ([i '(1 2 3 4 5)]) (display ...
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