Recursion and Stack overflow
Recursion and Stack overflow
- Subject: Recursion and Stack overflow
- From: Justin Laden <email@hidden>
- Date: Thu, 3 Dec 2009 13:49:49 -0500
Hi everyone,
I'm trying something in AppleScript that may not be possible, but I'd
like to find out, so I can more fully understand the limits and
capabilities of the language.
I'm trying to test a recursive algorithm which I found on page 328 of
the Cormen text, "Introduction to Algorithms, Second Edition".
(sometimes I use AppleScript to quickly test algorithms and computer
science ideas, instead of using C or Java)
I have implemented the algorithm, but when I run it, the script ends
in a "Stack overflow" error.
Here is my code:
if contents of i is 1 then
--return shortest path through assembly line
display dialog "done"
else
--make the recursive call
set item i of List1 to (minNum((recAssem((item (i - 1) of List1)) +
(item i of L1T)), (recAssem((item (i - 1) of List2)) + (item (i - 1)
of TT2) + (item i of L1T))))
end if
Clearly complicated--and better done in another language--but is there
any way around the Stack overflow error? What are the limits of
recursion in AppleScript?
Any help would be appreciated, especially if Mr. Neuburg or Mr.
Berkowitz or any other advanced AppleScripters could shed some light
on the deeper recursion issue.
Thanks!
-Justin
_______________________________________________
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