Re: Best practices- nested loops or handlers or both
Re: Best practices- nested loops or handlers or both
- Subject: Re: Best practices- nested loops or handlers or both
- From: Paul Berkowitz <email@hidden>
- Date: Mon, 01 Nov 2004 16:45:35 -0800
On 11/1/04 4:25 PM, "Neil Faiman" <email@hidden> wrote:
> The example below isn't quite right. As written, the recursive call
> computes the proper next business day, but nothing gets done with it;
> instead, we return the value that was assigned by the assignment "d = d
> + 1", even if it got re-incremented in the recursive call. This ought
> to be:
>
> on getNextBusinessDay(d)
> if isWeekend(d) or isHoliday(d) then
> return getNextBusinessDay(d+1)
> else
> return d
> end if
> end getNextBusinessDay
>
> But recursion is overkill in this example. A simple loop works just as
> well:
>
> on getNextBusinessDay(d)
> repeat while isWeekend(d) or isHoliday(d)
> d = d + 1
> end repeat
> return d
> end getNextBusinessDay
>
Here are two of you blithely assertion that
d = d + 1
is an assignment. Not in AppleScript it ain't. ;-) It's an equality
statement which - by definition - is always going to be false. The value for
d will never change and the recursion will be endless. I think you both must
mean to say:
set d to d + 1
Yes?
--
Paul Berkowitz
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden