Message: 12
Date: Fri, 22 Jul 2005 08:04:53 -0700
From: Geoff Canyon <[EMAIL PROTECTED]>
Subject: Re: NPR puzzle
To: How to use Revolution <[email protected]>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
The engine optimizes the tests in conditionals. So in this statement:
if a=3 and b=2 then...
b never gets evaluated if a is not 3. I rewrote Dick's very nice code
using this principle, to get rid of the nested if statements.
Interestingly, my code slowed down a couple milliseconds. Just from
13 to 15, but I wonder why that might be. Maybe the engine goes to
the trouble of getting the substrings before doing the tests.
Here's the code:
put the milliseconds into tMilliseconds
repeat for each line tSymbol in field 2
put "true" into S[tSymbol]
end repeat
repeat for each word W in field 1
if S[char 1 to 2 of W] and \
S[char 3 to 4 of W] and \
S[char 5 to 6 of W] and \
S[char 7 to 8 of W] and \
S[char 9 to 10 of W] then \
put W & return after tHits
end repeat
put the milliseconds - tMilliseconds into tElapsedMilliseconds
put number of lines in tHits && "hits in" \
&& tElapsedMilliseconds && "milliseconds" \
& return & return & tHits
Geoff,
It appears that RR also does not continue with the nested ifs after
it gets a false. I put a "beep" after the next to last if in Dick's
handler and the handler only beeped once.
Jim
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution