Last active
December 27, 2015 03:09
-
-
Save qcom/7257781 to your computer and use it in GitHub Desktop.
return the elements of a list with an odd index (1, 3, 5, etc.)
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
(define (odds lis) | |
(reverse (odds-reduce lis '()))) | |
(define (odds-reduce l1 l2) | |
(cond | |
((null? l1) l2) | |
((= (length l1) 1) (cons (car l1) l2)) | |
(else (odds-reduce (cddr l1) (cons (car l1) l2))) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment