Created
April 5, 2016 07:13
-
-
Save danhper/e43b6f07b6d77cbf29384832d7e74a0e 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 MyClass: | |
def __init__(self, high_order, applied): | |
self.high_order_func = high_order | |
self.applied_func = applied | |
def call(self, values): | |
return self.high_order_func(self.applied_func, values) | |
def main(): | |
inst = MyClass(map, lambda x: x + 1) | |
print(list(inst.call([1, 2, 3]))) | |
print(list(inst.high_order_func(inst.applied_func, [1, 2, 3]))) | |
inst = MyClass(filter, lambda x: x > 1) | |
print(list(inst.call([1, 2, 3]))) | |
print(list(inst.high_order_func(inst.applied_func, [1, 2, 3]))) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment