Created
August 24, 2020 10:54
-
-
Save EkremDincel/f9b9ce42469cd287f307ec3861ae30bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import reduce, partial | |
import itertools as it | |
from operator import itemgetter, methodcaller | |
def reversed_partial(f, *args, **kwargs): | |
def wrapper(*_args, **_kwargs): | |
f(*_args, *args, **_kwargs, **kwargs) | |
return wrapper | |
def unpack(iterable): | |
for i in iterable: | |
yield from i | |
def fmap(obj, functions): | |
for f in functions: | |
yield f(obj) | |
class Subsequence(): | |
def __init__(self, sequence): | |
self.sequence = sequence | |
self.start = 0 | |
self.finish = len(sequence) | |
def upto(self, finish): | |
self.finish = self.start + finish | |
return self | |
def startfrom(self, start): | |
self.start += start | |
return self | |
def between(self, start, finish): | |
self.finish = self.start + finish | |
self.start += start | |
def __getitem__(self, index: int): | |
return self.sequence[self.start + index] | |
def __len__(self): | |
return self.finish - self.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment