; rotated palindrome

(define (split n xs)
  (let loop ((n n) (xs xs) (zs '()))
    (if (or (zero? n) (null? xs))
        (values (reverse zs) xs)
        (loop (- n 1) (cdr xs) (cons (car xs) zs)))))

(define (string-reverse str)
  (list->string (reverse (string->list str))))

(define (string-rotate n str)
  (call-with-values
    (lambda () (split n (string->list str)))
    (lambda (front back) (list->string (append back front)))))

(define (rot-pal? str)
  (let loop ((n (string-length str)) (str str))
    (if (zero? n) #f
      (if (string=? str (string-reverse str)) #t
        (loop (- n 1) (string-rotate 1 str))))))

(display (rot-pal? "abcdedcba")) (newline)
(display (rot-pal? "dedcbaabc")) (newline)
(display (rot-pal? "abcdefghi")) (newline)