; string rotations

(define (take n xs)
  (let loop ((n n) (xs xs) (ys '()))
    (if (or (zero? n) (null? xs))
        (reverse ys)
        (loop (- n 1) (cdr xs)
              (cons (car xs) ys)))))

(define (rots xs)
  (let ((len (length xs)))
    (do ((xxs (append xs xs) (cdr xxs))
         (rots (list) (cons (take len xxs) rots))
         (n len (- n 1))) ((zero? n) rots))))

(define (string-rotations str)
  (map list->string (rots (string->list str))))

(display (string-rotations "Praxis")) (newline)
