Re: Incremental Character Generator
Re: Incremental Character Generator
- Subject: Re: Incremental Character Generator
- From: Nigel Garvey <email@hidden>
- Date: Wed, 22 Nov 2000 13:24:55 +0000
In my message of Wednesday, 22 November 2000 12:05:11, I wrote:
>
This version of Michelle's script handles any alphabet, copes with
>
out-of-sequence characters, and reduces calculation and concatenation
>
overheads:
>
>
set alphabet to "adbcdefghijklmnovpqrs_tu|vwxyz"
>
repeat with chr1 in alphabet
>
set t to chr1
>
repeat with chr2 in alphabet
>
set te to t & chr2
>
repeat with chr3 in alphabet
>
set tes to te & chr3
>
repeat with chr4 in alphabet
>
set test to tes & chr4
>
--do something with test
>
end repeat
>
end repeat
>
end repeat
>
end repeat
>
>
NG
If, on the other hand (rereading the original post!), you don't want to
generate the entire sequence but just get the next string in it from a
given input, this might be preferable:
on strInc(str, alphabet)
if alphabet ends with character -1 of str then
if (count str) > 1 then
strInc(text 1 thru -2 of str, alphabet) & character 1 of alphabet
else
character 1 of alphabet
end if
else
(offset of (character -1 of str) in alphabet) + 1
text 1 thru -2 of str & character result of alphabet
end if
end strInc
set alphabet to "adbcdefghijklmnovpqrs_tu|vwxyz"
strInc("keinproblel", alphabet)
NG