use unix newlines everywhere
[debienna.git] / FactTailCall / index.mdwn
1 FactTailCall hier beschreiben...
2
3 {{{
4 import sys
5
6 def fact(x):
7         ##print 'entered fact ', x
8         if x==1:
9                 result= 1
10         else:
11                 result= fact (x-1)*x
12         print 'leaving fact ', result
13         return result
14
15
16 def fact_tail_call(x,c):
17         #print 'entered fact_ ', x, ' ', c
18         if x==1:
19                 print c
20                 raise 'done'
21                 #result= c
22         else:
23                 result= fact_ (x-1,c*x)
24         print 'leaving fact_ ', result
25         return result
26
27 fact (200)
28 fact_tail_call (200, 1)
29 }}}
30
31 ----
32 CategoryCodeSnippets