Created
September 19, 2019 22:00
-
-
Save victorusachev/eeff254122cf03962a2a9d0073f1871b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class List: | |
| def __init__(self, items): | |
| super().__init__() | |
| self._items = items | |
| def __call__(self, function): | |
| self._items = map(function, self) | |
| return self | |
| def __iter__(self): | |
| return iter(self._items) | |
| @property | |
| def result(self): | |
| self._items = tuple(self._items) | |
| return self._items | |
| def main(data, functions): | |
| functor = List(data) | |
| for func in functions: | |
| functor = functor(func) | |
| yield functor.result | |
| if __name__ == '__main__': | |
| stages = main( | |
| data=(-2, -1, 0, 1, 2, 21), | |
| functions=(abs, float, str, reversed, list, ''.join, float) | |
| ) | |
| for stage in stages: | |
| print(stage) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment