builtup4/bu4/evaluation/constructs/eilambda.py
2021-09-09 08:16:01 +03:00

28 lines
854 B
Python

# Copyright (c) PARRRATE T&V 2021. All rights reserved.
from bu4.evaluation.av.evtype import evtype
from bu4.evaluation.av.lambdaev import LambdaEv
from bu4.evaluation.constructs.attachable import Attachable
from bu4.evaluation.constructs.eattachable import EAttachable
from bu4.evaluation.constructs.evaluable import Evaluable
from bu4.evaluation.constructs.evalue import EValue
__all__ = ('EILambda',)
class EILambda(EValue):
def __init__(self, ev: evtype, value: Attachable[evtype], *, memoize: bool):
self.ev = ev
self.value = value
self.memoize = memoize
def call(self, argument: Evaluable) -> Evaluable:
ev: evtype = LambdaEv(self.ev, argument, memoize=self.memoize)
return EAttachable(
ev,
self.value
)
def __str__(self):
return f'(0){self.value}'