Thanks for condensing that Kai! I saw the trees, but the forest eluded
me.
As for avoiding TIDs collisions, how about this? Do you see any method
to do this that doesn't duplicate data and without using 'contains'? On
large data sets both of these are limiting factors.
on itemIndices(i, l)
set d to text item delimiters
set AppleScript's text item delimiters to ""
set listAsText to l as text
repeat with c from 0 to 255
set s to ASCII character c
set text item delimiters to s
if (length of text items of listAsText) is 1 then exit repeat
end repeat
set text item delimiters to s & s
set l to s & l & s
set text item delimiters to s & i & s
set l to l's text items
set text item delimiters to s
set c to 0
set i to {}
set o to (count l) - 1
repeat with n from 1 to o
set c to (count l's item n's text items) div 2 + 1 + c
set i's end to c
end repeat
set text item delimiters to d
{occurrences:o, indices:i}
end itemIndices