示例#1
0
 def plus2(x, y):
     h1 = make_cell(x)
     h2 = make_cell(y)
     increment(h1)
     increment(h2)
     increment(h1)
     increment(h2)
     return cell_get(h1), cell_get(h2)
示例#2
0
 def plus(x, y):
     h = make_cell(x)
     i = y
     while i > 0:
         increment(h)
         i = i - 1
     return cell_get(h)
示例#3
0
 def plus4(x):
     h = make_cell(x)
     increment(h)
     increment(h)
     increment(h)
     increment(h)
     return cell_get(h)
示例#4
0
 def plus(h, y):
     i = y
     while i > 0:
         increment(h)
         i = i - 1
     return cell_get(h)
示例#5
0
 def length(h, xs):
     if not isinstance(xs, Empty):
         increment(h)
         length(h, xs.tail)
     return cell_get(h)
示例#6
0
def increment(h):
    return cell_set(h, add_one(cell_get(h)))
示例#7
0
 def value(self):
     return cell_get(self._count)
示例#8
0
 def increment(self, inc):
     curr = cell_get(self._count)
     rval = curr + inc
     cell_set(self._count, rval)
     return rval