cl:butnthcdr   scheme


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

Implementation

(define (cl:butnthcdr k lst)
  (cond ((negative? k) lst) ;(slib:error "negative argument to butnthcdr" k)
          ; SIMSYNCH FIFO8 uses negative k.
  ((or (zero? k) (null? lst)) '())
  (else (let ((ans (list (car lst))))
    (do ((lst (cdr lst) (cdr lst))
         (tail ans (cdr tail))
         (k (+ -2 k) (+ -1 k)))
        ((or (negative? k) (null? lst)) ans)
      (set-cdr! tail (list (car lst))))))))


Back to Index