The Evolution of a Python Programmer
41–45 of 45 posts
Re: The Evolution of a Python Programmer
#42The original: http://www.willamette.edu/~fruehr/haskell/evolution.html (Haskell)
Re: The Evolution of a Python Programmer
#43Half of those are incorrect implementations that junk the stack and most of the rest are idiotic rebaked jokes from the late 90s. Nowhere near to http://www.willamette.edu/~fruehr/haskell/evolution.html which is not only enlightening but actually funny when it tries to; or even to http://www.ariel.com.au/jokes/The_Evolution_of_a_Programmer.... which was funny when it started and still is the original. Can we stop mak…
I actually thought this was the best thing I read today. So please don't stop posting these.
Re: The Evolution of a Python Programmer
#44Earlier quoted context omitted.
A 'lazier programmer' who actually checked the optimization of various factorial methods? There's a joke in there somewhere...
a lazy programmer is one who will write a shell script in an hour to generate three lines of boilerplate...
Re: The Evolution of a Python Programmer
#45 class Factorial(object):
def __init__(self):
self.n = 0
self.fact_n = 1
def next_fact(self):
self.fact_n *= (self.n + 1)
self.n += 1
def prev_fact(self):
self.fact_n /= self.n
self.n -= 1
def fact(self, n):
if n == self.n:
return self.fact_n
elif n > self.n:
# start from self.n working forward
self.next_fact()
return self.fact(n)
else:
# start from fact_n working backwards
self.prev_fact()
return self.fact(n)
fobj = Factorial()
print fobj.fact(6)
print fobj.fact(8)
print fobj.fact(3)