Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- from circuits import Component, Debugger, Event
- class factorial(Event): pass
- class App(Component):
- def factorial(self, n):
- time.sleep(1)
- if n > 1:
- nn = yield self.call(factorial(n-1))
- yield n * nn.value
- else:
- yield 1
- def started(self, *args):
- rv = yield self.call(factorial(5))
- print(rv.value)
- self.stop()
- (App() + Debugger()).run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement