rotatedeep   scheme


Defined in:  https://github.com/lambdamusic/extempore-extensions/blob/main/init/init_lisp.xtm

Implementation

;; rotatedeep
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Rotates a list of lists, so that the inner lists are also rotated.
;
; arg1: a list
; arg2: opt[default: -1] 1 or -1 to determine rotation direction
;
; Example
; (define l '((a b) (c d) (e f)) )
; (rotatedeep l) => ((c d) (e f) (a b))
;
(define rotatedeep
  (lambda (lst . amt)
   (if (null? amt)
      (set! amt -1)
      (set! amt (car amt)) 
      )    
    (rotate (append (list (rotate (car lst) amt)) (cdr lst)) amt)   
    ))


Back to Index