fork download
  1. ; two list tasks
  2.  
  3. (define (sum xs) (apply + xs))
  4. (define xss '((1 2 3 4) (2 3 4 5) (3 4 5 6)))
  5. (display (map sum (apply map list xss))) (newline)
  6.  
  7. (define (split n xs)
  8. (let loop ((n n) (xs xs) (zs '()))
  9. (if (or (zero? n) (null? xs))
  10. (values (reverse zs) xs)
  11. (loop (- n 1) (cdr xs) (cons (car xs) zs)))))
  12.  
  13. (define xs '(1 2 3 4 2 3 4 5 3 4 5 6))
  14. (define (splits n xs)
  15. (let loop ((xs xs) (zs (list)))
  16. (if (null? xs) (reverse zs)
  17. (call-with-values
  18. (lambda () (split n xs))
  19. (lambda (first rest)
  20. (loop rest (cons first zs)))))))
  21. (display (map sum (splits 4 xs))) (newline)
Success #stdin #stdout 0.04s 8196KB
stdin
Standard input is empty
stdout
(6 9 12 15)
(10 14 18)