June 2013
Intermediate to advanced
312 pages
6h 47m
English
#|
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.
|#
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 ...