[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: LOGO-L> Factorials



George Mills wrote:
> 
> Here is the "on demand" cache version I spoke of.
> 
> Note it runs slower (because it should).
> 
> Again it depends on your applications bevahvior as to its worth.
> It would payoff if the factorials needed were sparse (but still
> repeatedly used [multiple hits in the cache]).
> 
> If I made FACT any slower Erich's post might start to payoff :-)
> 
> to do
> make "start timemilli
> invalidate_fact_cache
> for[num 100 999][
>    if equalp :num(sum fact item 1 :num
>                       fact item 2 :num
>                       fact item 3 :num)
>    [pr :num]]
> show (timemilli - :start) / 600
> end
> 
> to fact :n
> if (item :n :factarr) = -1 [setitem :n :factarr fact_real :n]
> op item :n :factarr
> end
> 
> to fact_real :n
> op ifelse :n<2[1][:n*fact_real :n-1]
> end
> 
> to invalidate_fact_cache
> make "factarr(array 10 0)
> for[i 0 9][
>       setitem :i :factarr -1]
> end
> 
> do
> 145
> 3.54333333333333

Thanks George for that.

About the P-266: It's a job for experts to build a complete computer
around that mother board. This mail is composed on my new machine
though, but it will take some time before I can manage to rehabilitate
all the software and made them workable. I'm sure that by then you will
have completed the 3-D documentation and the implementation of SETHXYZ!

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