Skip to content

Commit

Permalink
added __call__ method (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
0lch4 authored Jul 26, 2024
1 parent 6f57ad5 commit 093329e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/middle-earth/call.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Composer:
def __init__(self, *functions):
self.functions = reversed(functions)

def __call__(self, args):
for function in self.functions:
args = function(args)
return args


if __name__ == "__main__":

def one(x):
return x + 1

def two(x):
return x + 2

def three(x):
return x + 3

call = Composer(one, two, three)
print(call(5))

0 comments on commit 093329e

Please sign in to comment.