Created
August 14, 2020 05:22
-
-
Save Abidzar16/13dcb30f3b4e68e2068d78a8ae3438f6 to your computer and use it in GitHub Desktop.
DE_Python soal nomor 2
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
def pipeline(*funcs): | |
def helper(arg): | |
argCount = len(funcs) | |
if argCount > 0: | |
res = [] | |
for elem in funcs: | |
if(len(res) > 0): | |
helper = elem(res.pop()) | |
else: | |
helper = elem(arg) | |
res.append(helper) | |
helper = res.pop() | |
return helper | |
return helper | |
fun = pipeline(lambda x: x * 3, lambda x: x + 1, lambda x: x / 2) | |
print(fun(3)) #should print 5.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment