[cse491] HW1: Reentrant Iterators

C. Titus Brown ctb at msu.edu
Thu Aug 28 20:04:29 PDT 2008


-> Okay, since the sequence is [0, 1, 1, 2, 3, 5, 8, 13, 21], shouldn't  
-> that code:
-> 
-> >x = homework1.FibonacciIterator(8)
-> >for a in x:
-> > for b in x:
-> >    print a, b
-> 
-> store 'a' as the first number in the sequence, then continue with b  
-> for the 2nd to last so you get:
-> 
-> 0 1
-> 0 1
-> 0 2
-> 0 3
-> 0 5
-> 0 8
-> 0 13
-> 0 21
-> 
-> with two 1s to start?

Yep, my mistake.

-> Anyway, the reason I asked about the tests was because the way you  
-> worded it
-> 
-> "ReentrantFibonacciIterator(n) - a re-entrant version of the fib  
-> iterator,
->     i.e. something that can be iterated over multiple times."
-> 
-> and the way you tested it made it seem like it was just an iterator  
-> that reset itself when it reached the end.  But thanks for the  
-> clarification =].

Good point!  I will put that into tests, thanks for pointing it out.

--t
-- 
C. Titus Brown, ctb at msu.edu



More information about the cse491-fall-2008 mailing list