Skip to content

Instantly share code, notes, and snippets.

@Abidzar16
Created August 14, 2020 05:22
Show Gist options
  • Save Abidzar16/13dcb30f3b4e68e2068d78a8ae3438f6 to your computer and use it in GitHub Desktop.
Save Abidzar16/13dcb30f3b4e68e2068d78a8ae3438f6 to your computer and use it in GitHub Desktop.
DE_Python soal nomor 2
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