Skip to content

Instantly share code, notes, and snippets.

@QuantumFractal
Last active September 27, 2016 20:33
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 QuantumFractal/c0a6606b303c8ced3f3c1c2fc5263b9d to your computer and use it in GitHub Desktop.
Save QuantumFractal/c0a6606b303c8ced3f3c1c2fc5263b9d to your computer and use it in GitHub Desktop.
342 Sum / Map Example
(define sum
(lambda (lst)
(if (null? lst)
0
(+ (car lst) (sum (cdr lst)))
)
)
)
(define map
(lambda (f lst)
(if (null? lst)
(list)
(cons (f (car lst)) (map f (cdr lst)))
)
)
)
(define a_list (list 1 2 3 4))
(define addone (lambda (x) (+ x 1)))
(sum (map addone a_list))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment