Last active
October 30, 2019 15:11
-
-
Save chelseatroy/a8627271846801f786af7a6d5f6008ac to your computer and use it in GitHub Desktop.
Collection Operations
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
; Collection Operations | |
(define (map proc items) | |
(if (null? items) | |
null | |
(cons (proc (car items)) | |
(map proc (cdr items))))) | |
(define (filter condition items) | |
(if (null? items) | |
null | |
(if (proc (car items)) | |
(cons (car items) (filter condition (cdr items))) | |
(filter condition (cdr items))))) | |
(define (append seq1 seq2) | |
(if (null? seq1) | |
seq2 | |
(cons (car seq1) (append (cdr seq1) seq2)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment