George Mills wrote: > > Note that it does not help that much improving the compute_facts > because it is now dominated by the compare and fact lookups > once the cache was added. > > Interestingly the code actually looks cleaner with this optimization. > It certainly helps performance but not as much as you might of > hoped for. > > Also note the one line of code I changed below for the purist. > Although some purists might like it the way you had it. > > > > =================================================== > > to main > > compute_facts > > solve > > end > > > > to compute_facts > > make "fact_array(array 10 0) > > setitem 0 :fact_array 1 > > for[i 1 9][ > > setitem :i :fact_array :i*item :i-1 :fact_array] > > setitem :i :fact_array :i*fact :i-1] <=========== > > > end > > > > to solve > > for[num 100 666][ > > if equalp :num(sum fact item 1 :num > > fact item 2 :num > > fact item 3 :num) > > [pr :num]] > > end > > > > to fact :n > > op item :n :fact_array > > end > > =================================================== George, I find your suggestion (I put an "arrow" next to it) to be a good one, though I might belong to the "purist" party. If my suggestion above save some time or not, is at this moment less important. Regards... [[Yehuda]] --------------------------------------------------------------- Please post messages to the Logo forum to logo-l@gsn.org. Mail questions about the list administration to logofdn@gsn.org. To unsubscribe send unsubscribe logo-l to majordomo@gsn.org.
Global SchoolNet Foundation -
Linking Kids Around the World!
Copyright GSN - All Rights Reserved
- Comments
& Questions
Visit GSN's
Global
Schoolhouse for more exciting learning resources!
Search our Site
-
Home