Skip to content

Instantly share code, notes, and snippets.

@chelseatroy
Last active October 29, 2019 22:06
Show Gist options
  • Save chelseatroy/e419afefdc4fd168f2972e9a5444f153 to your computer and use it in GitHub Desktop.
Save chelseatroy/e419afefdc4fd168f2972e9a5444f153 to your computer and use it in GitHub Desktop.
Mapping
; 2.21
(define (square-list1 items)
(if (null? items)
null
(cons (* (car items) (car items)) (square-list1 (cdr items)))
)
)
(define (square-list2 items)
(map (lambda (x) (* x x)) items)
)
(square-list1 (list 1 2 3 4))
(square-list2 (list 1 2 3 4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment