Skip to content

Instantly share code, notes, and snippets.

@wkta
Created March 30, 2014 15:54
Show Gist options
  • Save wkta/9874822 to your computer and use it in GitHub Desktop.
Save wkta/9874822 to your computer and use it in GitHub Desktop.
#MonthOfCode day 23 - meta
# This shows how we can define and use a META-function in python
def produce_incrementor( step):
''' it produces various increment functions'''
return lambda u:u+step
print "three by three"
increm_three = produce_incrementor(3)
k=0
while k < 34:
print k
k = increm_three( k)
print "eleven by eleven"
increm_three = produce_incrementor(3)
k=0
while k < 34:
print k
k =\
produce_incrementor(11)(k) #immediate call of the func returned by produce_incrementor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment