split-by   scheme


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/examples/contrib/word_count.xtm

Implementation

(define split-by
  (lambda (n lst)
    (let ((list-size (length lst)))
      (if (not (= 0 (modulo list-size n)))
          (println "list length must be divisible by n"))
      (if (null? lst)
          '()
          (cons (take lst n) (split-by n (drop lst n)))))))


Back to Index