use-revolution Digest, Vol 22, Issue 14
Alex Tweedly
alex at tweedly.net
Mon Jul 4 19:03:28 EDT 2005
Richard Gaskin wrote:
>
> Since each pass through the loop involves checking for the same number
> of steps (4), could a stop option in the repeat statement be helpful?
>
step option ? That might help a bit -
I'm not quite sure how you'd add a "step" option to the "repeat for each
char" form (nb we need to access almost every character, not just every
fourth one). I guess you could invent some syntax like
repeat for each 4 chars (c1,c2,c3,c4) in the imageData of img "image"
add 1 to histo[chartonum(c2) + chartonum(c3) + chartonum(c4)]
end repeat
at a (very) rough count, that could maybe save 50% !!
N loop repeats / tests
4N char assignments
3N retrieves
2N additions
N array lookups
N additions
versus
> repeat for each char c in lImageData
> add chartonum(c) to temp
> add 1 to count
> if count = 4 then
> add 1 to histo[temp]
> end if
> put 0 into temp
> put 0 into count
> end repeat
4N loop repeats / test
4N char assignments
4N additions
4N tests
N array lookups
N additions
4N assignments
4N assignments
So I think the addition of a "step" option to the "repeat for each" form
of loop would be worthwhile - and I hope someone can come up with a
better syntax than I used above !!
--
Alex Tweedly http://www.tweedly.net
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.8.8/37 - Release Date: 01/07/2005
More information about the use-livecode
mailing list