rotate   scheme


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/runtime/scheme.xtm

Implementation

;; rotate list
(define rotate
   (lambda (lst amt)
      (let loop ((l (if (> amt 0) (reverse lst) lst))
     (cnt (abs amt)))
   (if (<= cnt 0)
       (if (> amt 0) (reverse l) l)
       (loop (append (cdr l) (list (car l)))
       (- cnt 1))))))


Back to Index

Similar Entries