Skip to content

Instantly share code, notes, and snippets.

@h2rd
Last active December 28, 2015 07:38
Show Gist options
  • Select an option

  • Save h2rd/7465358 to your computer and use it in GitHub Desktop.

Select an option

Save h2rd/7465358 to your computer and use it in GitHub Desktop.
function
def fabric(fnum):
def add(num):
return fnum + num
return add
def addition(num):
return lambda x, num=num: x+num
if __name__ == '__main__':
add3 = fabric(3)
assert add3(4), 7
assert add3(7), 10
assert add3(10), 13
add5 = addition(5)
assert add5(4), 9
assert add5(7), 12
assert add5(10), 15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment