From: Ross Bamford Date: 2006-03-25T00:07:01+09:00 Subject: Re: iterator class not working On Fri, 2006-03-24 at 23:43 +0900, Robert Dober wrote: > > Well I got it! > Was I missing something or is my solution really better? Well, if you're going to cheat and use return ... :) Seriously though, I like that one. Shows how it's important to remember the 'normal' stuff when you're thinking in this high level stuff :) And yes, I guess it is better: user system total real Iterator1 4.730000 0.040000 4.770000 ( 4.877037) Iterator2 2.840000 0.050000 2.890000 ( 2.960747) Iterator3 2.800000 0.130000 2.930000 ( 2.998121) Iterator4 2.040000 0.020000 2.060000 ( 2.131763) (1 = my updated, easy to follow version of Peter's original, 2 = same version with one callcc and one catch, 3 = Peter's second implementation, 4 = your callcc/return implementation) As you can see, though, they're all pretty slow when it comes right down to it (this was only over (0...50000).to_a) - some of the FasterGenerator quiz entries I mentioned achieved quite amazing speeds over that many iterations and more - you should check them out. -- Ross Bamford - rosco@roscopeco.REMOVE.co.uk