Hi Rodolfo, Thanks for the suggestion. I ended up reading quite a bit about generators and found this very appropriate and interesting page: http://matthias.benkard.de/journal/116.
-Joe On Sun, Feb 19, 2012 at 7:05 PM, Rodolfo Carvalho <rhcarva...@gmail.com>wrote: > On Mon, Feb 20, 2012 at 00:55, Joe Gilray <jgil...@gmail.com> wrote: > >> Hi Rodolfo, >> >> Thanks for the suggestions. Your re-factoring (no pun intended) of the >> conds really cleaned things up. Much appreciated. >> >> About the unnecessary loops, good point, I simply changed to starting >> with end set to 10 instead of 1000 and I think that helps a lot. I know >> that there are other gross inefficiencies as well (for example, if >> primes-from-to gets called to just add a few primes to the list it is very >> slow as it goes through the whole list. A better implementation would >> "know" that the values on storedlst are already checked and skip checking >> them. >> > > > Maybe you could generate the list of primes using... hmm.. Generators! > > http://docs.racket-lang.org/reference/Generators.html > > You could have something like (primes-up-to n) yield one prime at a time, > up to n (the number to be factored). > > > []'s > > Rodolfo Carvalho >
____________________ Racket Users list: http://lists.racket-lang.org/users