25 lines
740 B
Python
25 lines
740 B
Python
# Copyright (c) PARRRATE T&V 2021. All rights reserved.
|
|
|
|
from typing import Sequence
|
|
|
|
from bu4.evaluation.constructs.evaluable import Evaluable
|
|
from bu4.evaluation.targets.avanonymouscontainer import AVAnonymousContainer
|
|
from bu4.indexing.evaluation.eivtype import eivtype
|
|
|
|
__all__ = ('LambdaEiv',)
|
|
|
|
|
|
class LambdaEiv(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: eivtype, evaluable: Evaluable, *, memoize):
|
|
self.ev = ev
|
|
self.container = AVAnonymousContainer(evaluable).after_value if memoize else evaluable
|