From: Tyler Prete Date: 2006-12-05T05:37:45+09:00 Subject: Re: [QUIZ] Turtle Graphics (#104) [SOLUTION] ------=_Part_49355_9221495.1165264628638 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Very nice. I didn't think to use mod for the angle correction either, but that is definitely the more elegant solution. --Tyler Prete On 12/4/06, Paul Lutus wrote: > > Morton Goldberg wrote: > > / ... > > > case > > when @heading >= 360.0 > > @heading -= 360.0 while @heading >= 360.0 > > @heading %= 360 > > > when @heading < 0.0 > > @heading += 360.0 while @heading < 0.0 > > @heading %= 360 # same solution > > In fact, now that I think about it, the entire block: > > case > when @heading >= 360.0 > @heading -= 360.0 while @heading >= 360.0 > when @heading < 0.0 > @heading += 360.0 while @heading < 0.0 > end > > can be replaced with: > > @heading %= 360 > > For a net improvement in execution speed and readability. > > I hope this doesn't come off as golfing, apparently a popular pastime > here. > > -- > Paul Lutus > http://www.arachnoid.com > > ------=_Part_49355_9221495.1165264628638--