예제 #1
0
파일: boolean.py 프로젝트: yuhangwang/amino
 def flat_m(self, v):
     return call_by_name(v) if self else maybe.Empty()
예제 #2
0
파일: boolean.py 프로젝트: yuhangwang/amino
 def m(self, v):
     return maybe.Maybe(call_by_name(v)) if self else maybe.Empty()
예제 #3
0
파일: boolean.py 프로젝트: yuhangwang/amino
 def flat_maybe_call(self, f, *a, **kw):
     return f(*a, **kw) if self else maybe.Empty()
예제 #4
0
파일: boolean.py 프로젝트: yuhangwang/amino
 def flat_maybe(self, value: 'Maybe'):  # type: ignore
     return value if self else maybe.Empty()
예제 #5
0
파일: boolean.py 프로젝트: yuhangwang/amino
 def maybe_call(self, f, *a, **kw):
     return maybe.Just(f(*a, **kw)) if self else maybe.Empty()
예제 #6
0
 def lift(self, index: int) -> 'maybe.Maybe[A]':
     return ((maybe.Just(self[index])
              if len(self) > index else maybe.Empty()) if index >= 0 else
             (maybe.Just(self[index])
              if len(self) >= -index else maybe.Empty()))
예제 #7
0
파일: boolean.py 프로젝트: yuhangwang/amino
 def maybe(self, value):
     return maybe.Maybe(value) if self else maybe.Empty()
예제 #8
0
 def tail(self) -> 'maybe.Maybe[List[A]]':
     return maybe.Empty() if self.empty else maybe.Just(self[1:])
예제 #9
0
 def init(self) -> 'maybe.Maybe[List[A]]':
     return maybe.Empty() if self.empty else maybe.Just(self[:-1])
예제 #10
0
 def find_map(self, fa: List[A], f: Callable[[A], Maybe[B]]) -> Maybe[B]:
     for el in fa:
         found = f(el)
         if found.present:
             return found
     return maybe.Empty()
예제 #11
0
 def tail(self) -> maybe.Maybe['List[A]']:
     return maybe.Empty() if self.empty else maybe.Just(self[1:])
예제 #12
0
 def init(self) -> maybe.Maybe['List[A]']:
     return maybe.Empty() if self.empty else maybe.Just(self[:-1])