(defun rev-word-order (str) (reverse (word-tokenize str))) ;; word-tokenize tokenisiert str in eine Liste von Worten, die aus alphanumerischen Zeichen ;; bestehen. Nicht alphanumerische Zeichen werden als whitespace behandelt. (defun word-tokenize (str) (let ((word) (nextpos)) (loop with acc = nil with pos = (position-if #'alphanumericp str :start 0) while (not (null pos)) finally (return (reverse acc)) do (setf nextpos (position-if-not #'alphanumericp str :start pos)) (setf word (subseq str pos nextpos)) (push word acc) (if (not (null nextpos)) (setf pos (position-if #'alphanumericp str :start nextpos)) (setf pos nil)))))