Skip to content

Instantly share code, notes, and snippets.

@chelseatroy
Last active October 30, 2019 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chelseatroy/a8627271846801f786af7a6d5f6008ac to your computer and use it in GitHub Desktop.
Save chelseatroy/a8627271846801f786af7a6d5f6008ac to your computer and use it in GitHub Desktop.
Collection Operations
; 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