Created
March 30, 2014 15:54
-
-
Save wkta/9874822 to your computer and use it in GitHub Desktop.
#MonthOfCode day 23 - meta
This file contains 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
# 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