class FactCPS:
def __init__(self, n, k):
self.k=k
self.n=n
def run(self):
if self.n==0:
return self.k(1)
else:
return factcps(self.n-1, self.cps)
def cps(self, v):
return self.k(self.n*v)
def factcps(n,k):
return FactCPS(n,k).run()
>>> def pr(v):
... print v
...
>>> factcps(5,pr)
120
Steve
-- Steven Miale - smiale@cs.indiana.edu| I was there at the dawn of the third age Indiana University, Bloomington, IN | of man, and all I got was this lousy .sig