From: khamidou Date: Thu, 11 Aug 2011 12:26:08 +0000 (+0200) Subject: cleaned dup code X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=f3a040982dcad817b73b95f30e53771864dec1a6;p=scaletool.git cleaned dup code --- diff --git a/scales.py b/scales.py index c066d8e..9ee7a24 100644 --- a/scales.py +++ b/scales.py @@ -83,15 +83,10 @@ class Scale: i = 0 j = 0 while i < 11 and j < 6: # reduce(lambda x,y: x+y, self.values) - note = notes[i] - if self.formula[j] == 1: - retscale += notes[i+1] - i += 1 - elif self.formula[j] == 2: - retscale += notes[i+2] - i += 2 - - j += 1 + n = self.formula[i] + retscale += notes[i+n] + i += n + j += 1 # Don't forget to increment j to avoid looping. retscale += " " return retscale