Files
why3/examples/python/sum_reverse.py
paulpatault 3671864507 Python: Added examples
- New examples using the new syntax (+=, ...)
- New examples using the new methods (.pop(), .append(), ...)
- Update old examples with assignement operators (+=, ...)
2021-06-24 11:44:07 +02:00

11 lines
205 B
Python

def sum_reverse (l):
#@ ensures result == 0
l2 = l.copy()
l2.reverse()
t = 0
for i in range (len(l)):
#@ invariant t == 0
t += l[i]
t -= l2[-(i+1)]
return t