Regarding the various palindrome routines that have been posted here:
I find it interesting an amusing that all of you are substringing the whole input string, letter by letter from first to last. Wouldn't it be quicker to check only the letters from the first half of the input string?
So instead of something like that:
use something like that:Code:j:=LENGTH(word); FOR i IN 1..j LOOP IF SUBSTR(word,i,1) != SUBSTR(word,j-i+1,1) THEN ...
Code:j:=TRUNC(LENGTH(word)/2); FOR i IN 1..j LOOP IF SUBSTR(word,i,1) != SUBSTR(word,-i,1) THEN ...




Reply With Quote