l-99

solutions to l-99 (slow)
Log | Files | Refs | Feed | README

commit 9e19d6008110c25856cdc57cfba5c6231034dba1
parent 38a31507368c4b55119ff9463c3561fb654f654c
Author: Jenny Doe <tng@soykaf.me>
Date:   Mon,  8 Apr 2019 16:08:11 +0200

added: p17.scm

Diffstat:
Ap17.scm | 16++++++++++++++++
1 file changed, 16 insertions(+), 0 deletions(-)

diff --git a/p17.scm b/p17.scm @@ -0,0 +1,16 @@ +; (*) 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)) + +(define (first-nths ls n) + (if (zero? n) + '() + (cons (car ls) + (first-nths (cdr ls) (- n 1))))) + +(define (split ls n) + (list (first-nths ls n) + (list-tail ls n)))