Hello You'All:
        Being my own most demanding critic, I wrote a function
to find the matching index of a character in a string.
I submitted that function, and have gotten three versions
of an improvement upon the algorithm. All are obviously
an improvement over mine.

I would love to see some input and discussion as to what 
is the most efficient of the three functions. Forgive me,
but I just can't help myself - my first paying programming
work was writing C and Assembly for a 286. I've always been
miserly when it came to machine overhead.

I wouldn't consider readability to be an issue, because
this would not be a function that would need any maintenance.

Here goes:
char-pos0: func [str [string!] ch [char!] /ndx]
[
  any[all [ndx: find/case str ch index? ndx] 0]
]
char-pos1: func [str[string!] ch[char!] /local result]
[
   either result: find/case str ch [index? result] [0]
]
char-pos2: func [str[string!] ch[char!] /local result]
[
   either found? result: find/case str ch [index? result][0]
]

Reply via email to