delete-at-index   scheme


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

Implementation

;;delete from list at index
(define delete-at-index
   (lambda (k lst)
      (cond ((or (null? lst)
     (< k 0))
       lst)
      ((= k 0)
       (cdr lst))
      ((>= k (length lst))
       lst)
      (else (set-cdr! (cl:nthcdr (- k 1) lst)
          (cl:nthcdr (+ k 1) lst))
      lst))))


Back to Index