hw7 - Suggested Homework #8 Suggested Homework #7 (for Quiz...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Suggested Homework #8 Suggested Homework #7 (for Quiz #7 on 11/16/06) Consider the Python code below: class Count: ctr = 0 def __init__(self,init,fnext): self.ctr = init self.n = fnext def nextValue(self): return self.n(self.ctr) def next(self): self.ctr = self.nextValue() return self.ctr class DCount(Count): def nextValue(self): return self.n(self.n(self.ctr)) c = Count(1,lambda x: x + 1) d = DCount(1,lambda x: 2*x) c.next() d.next() f = d.next r1 = DCount.ctr r2 = c.ctr r3 = d.ctr r4 = f() r5 = Count.next(d) def accelerate(C,n): class aC(C): def next(self): for i in range(n): C.next(self) return self.ctr return aC E = accelerate(Count,5) e = E(0,lambda x: x + 1) r6 = e.nextValue() r7 = e.next() (a) What are the attributes of the namespace Count ? http://www.cs.ucsd.edu/classes/fa06/cse130/shw/shw7.html (1 of 3) [2/13/2008 5:26:13 PM]
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Suggested Homework #8 (b) What are the attributes of the namespace DCount ? (c)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This homework help was uploaded on 02/14/2008 for the course CSE 130 taught by Professor Jhala during the Fall '06 term at UCSD.

Page1 / 3

hw7 - Suggested Homework #8 Suggested Homework #7 (for Quiz...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online