S-99-17 Split a list into two parts; the length of the first part is given.
Do not use any predefined predicates.
Example:
(split '(a b c d e f g h i k) 3) ; => ((a b c) (d e f g h i k))
Solution:
(define (split xs n)
(let loop ((i n) (first '()) (second xs))
(if (or (zero? i) (null? second))
(list (reverse first) second)
(loop (- i 1) (cons (car second) first) (cdr second)))))