fork(2) download
  1. ; string rotations
  2.  
  3. (define (take n xs)
  4. (let loop ((n n) (xs xs) (ys '()))
  5. (if (or (zero? n) (null? xs))
  6. (reverse ys)
  7. (loop (- n 1) (cdr xs)
  8. (cons (car xs) ys)))))
  9.  
  10. (define (rots xs)
  11. (let ((len (length xs)))
  12. (do ((xxs (append xs xs) (cdr xxs))
  13. (rots (list) (cons (take len xxs) rots))
  14. (n len (- n 1))) ((zero? n) rots))))
  15.  
  16. (define (string-rotations str)
  17. (map list->string (rots (string->list str))))
  18.  
  19. (display (string-rotations "Praxis")) (newline)
  20.  
Success #stdin #stdout 0.01s 7928KB
stdin
Standard input is empty
stdout
(sPraxi isPrax xisPra axisPr raxisP Praxis)