Created
July 21, 2010 04:23
cars+cdrs, scheme, gauche
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use srfi-8) | |
(define (cars+cdrs ls . rest-lists) | |
(let1 lists (cons ls rest-lists) | |
(let loop ((lists lists)) | |
(if (null? lists) | |
(values '() '()) | |
(receive (ls rest-lists)(car+cdr lists) | |
(receive (a d)(car+cdr ls) | |
(receive (cars cdrs)(loop rest-lists) | |
(values (cons a cars)(cons d cdrs))))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment