Next: The pinch function pinch
Up: The Representation
Previous: The Representation
  Contents
We need to be able to calculate the inverse of a
given generator. So the inverse of 'a' is 'A', 'A' is 'a',
'b' is 'B' and 'B' is 'b'. This function, given a string composed
of generators rewrites the string by reversing the string and doing
a generator by generator replacement.
(defun inv (word)
"given a word, construct its inverse"
(let ((result (reverse word)))
(dotimes (i (length result))
(setf (elt result i)
(cond
((eq (elt result i) #\\a) #\\A)
((eq (elt result i) #\\b) #\\B)
((eq (elt result i) #\\A) #\\a)
((eq (elt result i) #\\B) #\\b))))
result))
root
2004-05-05