recursive method not reaching base case

possibilitybox possibilitybox at gmail.com
Wed Mar 23 20:51:42 EST 2005


i was working on implementing the original supermemo algorithm (see
http://www.supermemo.com/english/ol/sm2.htm for a description of it) in
a class, and i'd just finished up the first draft.  it works for
repetitions one and two, but on repetition three (you must manually
increment item.reps.) or higher it recurses until it reaches the limit.
 can someone point out what i'm doing wrong here?

here's the code:
class item:
	def __init__(self, key, value):
		self.key = key
		self.value = value
		self.reps = 1
		self.ef = 2.5
	def interval(self):
		if(self.reps==1):
			return 2
		if(self.reps==2):
			return 6
		return (self.interval() - 1) * self.ef




More information about the Python-list mailing list