[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

MISMATCH, From end.



About MISMATCH, with :from-end elected.  I'd like to know what (mismatch
"able" "table" :from-end t) returns.  The second MISMATCH paragraph in
the Laser manual says explicitly an index into sequence1 is returned.
The sequences are not of the same length and content, so the answer
isn't NIL.  The "-rightmost- position at which the sequences differ" is
-1, a totally useless result.  This cannot be right.  Is this right?  Or
is the answer NIL, or as I surmise, is this definition wrong?

I think that the :from-end result should be 1+ what it is defined in the
manual to be consistent with everything else.  (mismatch "fubar"
"foobar" :from-end t) should be 2, the number of elements skipped in
sequence1, or the index of the beginning of the matching substring.
The manual's answer of 1 seems very very peculiar.

Suppose I wanted to use this to implement a (what a crazy idea!) text
editor in Lisp.  I would use this function to control Insert/Delete
chars.  I would use (mismatch :from-end nil) to position the cursor.
Then (mismatch :from-end t) to give me a count (subtracting current
position) of characters to delete, delete them and insert the new
characters.  This arithmetic is correct only if the definition of
(mismatch :from-end) is corrected as I advise.  This argues for its
correctness.