Recursive Definition of Equals
Here are the details of string equality, written as a recursive definition.
Say that the two strings are StringA and StringB.
- If StringA has no characters and StringB has no characters, then the strings ARE equal.
- If StringA has no characters and StringB has some characters, then the strings are NOT equal.
- If StringA has some characters and StringB has no characters, then the strings are NOT equal.
- Otherwise,
- if the first character of StringA is different from the first character of StringB, then the strings are NOT equal.
- if the first character of StringA is the same the first character of StringB, then the strings are equal if the tails ARE equal.