123456789101112131415161718192021222324252627 |
- def toList(s):
- L = []
- for i in s:
- if i != '\n':
- L.append(i)
- return L
- def f(i,s,S = None):
-
- if not S:
- S = []
-
- if i == len(s):
- return S[0]
- a = s[i]
- if a.isdigit():
- S.append(a)
- return f(i+1,s,S)
- else:
- c = S.pop()
- d = S.pop()
- e = '%s%s%s'%(c,a,d)
- S.append(eval(e))
- return f(i+1,s,S)
|