Re: How can I format an integer ?
Re: How can I format an integer ?
- Subject: Re: How can I format an integer ?
- From: Jon Pugh <email@hidden>
- Date: Tue, 4 Nov 2008 16:53:20 -0700
At 7:45 PM -0500 11/4/08, Deivy Marck Petrescu wrote:
>Luther not to disagree with the above statement, indeed, recursion is much more CPU intensive, but, as Philip wrote above, it is more logical.
>As for being faster, it is but not by much.
>Using Smile's chrono function and computing up to 150! these are the times
There are certain problems, like the classic Towers of Hanoi, which are logically simpler using recursion, but the real reason to avoid recursion where possible is memory useage. 150 is not a large sample. When you start talking thousands and millions, that's where you'll see real differences. Recursion takes up stack space, which is limited and non-expandable on almost every operating system. In fact, this is recursion's greatest strength, it stores intermediate values on the stack for only the duration of the algorithm.
So, speed isn't the real problem, memory use is. In most cases, the iterative (loop) method will use considerably less memory.
Jon
http://en.wikipedia.org/wiki/Tower_of_Hanoi
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden