Changing to FOR may be a tad slower than REPEAT but the bulk of the time is now simply fetching the correct precalculated value from the "factorial cache". If things were real large and less predicatable you can also Fill the "cache" on demand. You do this by "tagging" each entry as to its validity. Since now you won't be needing the P266 I'll give you an address you can forward it to :-). Yehuda Katz wrote: > > Hello George, > > Thank for your nice tip. It can serve as a nice introduction to the > subject of arrays in Logo, and I'm going really to use it. > > I modified your program a little bit, probably at the cost of some > slower performance, by trading REPEAT with FOR (in compute_facts). > > ======================================= > to do > compute_facts > for[num 100 999][ > if equalp :num(sum fact item 1 :num > fact item 2 :num > fact item 3 :num) > [pr :num]] > end > > to compute_facts > make "factarr(array 10 0) > for[i 0 9][ > setitem :i :factarr fact_real :i] > end > > to fact :n > op item :n :factarr > end > > to fact_real :n > op ifelse :n<2[1][:n*fact_real :n-1] > end > ======================================= > > 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. -- =============================================================== George Mills email: mills@softronix.com http://www.softronix.com The www page contains some very powerful educational software. Our single most important investment is our kids. --------------------------------------------------------------- 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