cl:slice-left   scheme


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

Implementation

;
; slice a list from beginning, returns a list
; (cl:slice-left '(1 2 3 4) 2) ;; => (1 2)
; (cl:slice-left '(1 2 3 4) 7) ;; => (1 2 3 4)
(define cl:slice-left
    (lambda (lst num)
       (if (< (length lst) num)
           (begin (println "Warning: list slicing index too big!")
                  (set! num (length lst))))
      (if (> num 0)
         (cons (car lst) (cl:slice-left (cdr lst) (- num 1)))
         '())))


Back to Index