Skip to content

Instantly share code, notes, and snippets.

@danhper
Created April 5, 2016 07:13
Show Gist options
  • Save danhper/e43b6f07b6d77cbf29384832d7e74a0e to your computer and use it in GitHub Desktop.
Save danhper/e43b6f07b6d77cbf29384832d7e74a0e to your computer and use it in GitHub Desktop.
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