Introduction to Iterators
by Holger Klawitter
Table of Contents
I
ntroduction
I
terators for beginners
while
and
repeat-until
-loops
for
-loops
Exercise 1
Some other nifty predefined iterators
W
riting iterators
How an iterator works
A first iterator with a single
quit
A single
yield
Exercise 2
Exercise 3
Control flow in an iterator
More than one iterator per loop
Iterators more than once in a loop
Exercise 4
I
terators for experts
What are once arguments?
Exercise 5
'self' is always 'once'
Variable declaration in iterators
Recursive iterators
Exercise 6
Iterators in complex expressions
Exercise 7
S
olutions for some of the exercises
Last modified: 07/09/96
Dipl. math.
Holger Klawitter
(holger@icsi.berkeley.edu).