예제 #1
0
class Value():
    def __init__(self, value):
        self.value = value
        self.variable = Lazy(lambda: self.value)

    def update(self, value):
        if not (value1 == self.value):
            self.value = value1
            self.variable.update(lambda: value1)
    
    #I'm not confident that this will actually trigger a 'dirtying change' maybe use value.variable.force() instead 
    def force(self): 
        temp = self.variable.force()
        return temp
예제 #2
0
from Adapton.Lazy import *
from adapton_list import *


x = Lazy(lambda: 1)
y = Lazy(lambda: 2)
z = Lazy(lambda: x.force() + y.force())
print z.force()
x.update(lambda: 5)
print z.force()
y.update(lambda: 6)
print z.force()


#For the following two test cases, outputs are 14 and 23
a = [Lazy(lambda: 13)]
x = Lazy(lambda: a[-1].force())
a.append(Lazy(lambda: 14))
print x.force()


a = [Lazy(lambda: 23)]
x = Lazy(lambda: a[-1].force())
x.force()
a.append(Lazy(lambda: 24))
print x.force()

#The following is the correct way of Adapt array
pp = [Lazy(lambda: 3), Lazy(lambda: 4)]
i = 1
x = Lazy(lambda i = i: pp[i].force())
예제 #3
0
 def __init__(self, value):
     self.value = value
     self.variable = Lazy(lambda: self.value)