• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How can I format an integer ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How can I format an integer ?


  • Subject: Re: How can I format an integer ?
  • From: Barry Wainwright <email@hidden>
  • Date: Wed, 05 Nov 2008 06:43:28 +0000


On 4 Nov 2008, at 23:53, Jon Pugh wrote:

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

While I don't disagree in principle and I don't use recursion in many places, this particular purpose will rarely recurse more than 3 or 4 times through the loop as it is intended for formatting integers, rather than very long numbers.


Recursion in this particular case is safe enough.

--
Barry


_______________________________________________ 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
References: 
 >Re: How can I format an integer ? (From: Barry Wainwright <email@hidden>)
 >Re: How can I format an integer ? (From: Philip Aker <email@hidden>)
 >Re: How can I format an integer ? (From: Luther Fuller <email@hidden>)
 >Re: How can I format an integer ? (From: Deivy Marck Petrescu <email@hidden>)
 >Re: How can I format an integer ? (From: Jon Pugh <email@hidden>)

  • Prev by Date: Re: How can I format an integer ?
  • Next by Date: Re: Install in Dock
  • Previous by thread: Re: How can I format an integer ?
  • Next by thread: Re: How can I format an integer ?
  • Index(es):
    • Date
    • Thread