# Copyright (c) PARRRATE T&V 2021. All rights reserved. from typing import Sequence from bu4.evaluation.av.evtype import evtype from bu4.evaluation.constructs.evaluable import Evaluable from bu4.evaluation.targets.avicontainer import AVIContainer __all__ = ('LambdaEv',) class LambdaEv(Sequence[Evaluable]): def __getitem__(self, i: int) -> Evaluable: if i == 0: return self.container else: return self.ev[i - 1] def __len__(self) -> int: return len(self.ev) + 1 def __init__(self, ev: evtype, evaluable: Evaluable, *, memoize): self.ev = ev self.container = AVIContainer(evaluable).after_value if memoize else evaluable