fork download
  1. ; partial list reversal
  2.  
  3. (use-modules (srfi srfi-11))
  4.  
  5. (define (split n xs)
  6. (let loop ((n n) (xs xs) (zs '()))
  7. (if (or (zero? n) (null? xs))
  8. (values (reverse zs) xs)
  9. (loop (- n 1) (cdr xs) (cons (car xs) zs)))))
  10.  
  11. (define (list-part-rev xs start finish)
  12. (let*-values (((temp end) (split finish xs))
  13. ((beginning middle) (split start temp)))
  14. (append beginning (reverse middle) end)))
  15.  
  16. (display (list-part-rev '(0 1 2 3 4 5 6 7 8 9) 3 6)) (newline)
Success #stdin #stdout 0s 42856KB
stdin
Standard input is empty
stdout
(0 1 2 5 4 3 6 7 8 9)