At 09:02 2009-07-17, Paul Newton <[email protected]> wrote:
>Is it ever possible to prove, scientifically or mathematically, that 
>two functions are exactly equivalent ?

      Yes, at the level of finite state automata.  It is not terribly 
practical in RL because there are so many possibilities that have to 
be checked.

>For example, these two functions:
>
>Function StripCharsNew(tcInvalidValue, tcValidCharSet)
>Local lcValidValue, lnCharNo
>lcValidValue = tcInvalidValue
>For lnCharNo = 1 to Len(tcInvalidValue)
>         If At(Substr(tcInvalidValue, lnCharNo, 1), tcValidCharSet) = 0
>                 lcValidValue = 
> ChrTran(lcValidValue,Substr(tcInvalidValue, lnCharNo, 1),tcReplaceChar)
>         EndIf
>Next
>Return lcValidValue
>EndFunc
>
>Function StripCharsOld(tcInvalidValue, tcValidCharSet)
>Local lcValidValue, lnCharNo
>lcValidValue    = ""
>For lnCharNo = 1 to Len(tcInvalidValue)
>         If At(Substr(tcInvalidValue, lnCharNo, 1), tcValidCharSet) > 0
>                 lcValidValue = lcValidValue + 
> Substr(tcInvalidValue, lnCharNo, 1)
>         EndIf
>Next
>Return lcValidValue
>EndFunc

      The functions are not equivalent.  The first does not define 
tcReplaceChar which it uses.  If tcReplaceChar were "", then the 
functions would be equivalent.

      Assuming that you want to strip out the invalid characters 
replacing them with "", try:
StrippedString=chrtran(RawString,chrtran(RawString,ValidChars,""),"")
The inner chrtran() strips out the valid characters returning a 
string of the characters in the original string that are 
invalid.  The outer chrtran() uses this string to strip out the 
invalid characters.

>Thanks

      You are welcome.

Sincerely,

Gene Wirchenko



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to