Skip to content

Instantly share code, notes, and snippets.

@quang-m-nguyen
Created March 10, 2017 07:51
Show Gist options
  • Save quang-m-nguyen/f0f4fa37f35b0e7c55a22afa99687685 to your computer and use it in GitHub Desktop.
Save quang-m-nguyen/f0f4fa37f35b0e7c55a22afa99687685 to your computer and use it in GitHub Desktop.
null created by quangogster - https://repl.it/GP0j/1
(define (addup L) (cond
((null? L) 0)
(else (+ (car L) (addup (cdr L))) ) )
)
(define (deepSum L) (cond
((null? L) 0)
((null? (car L))(+ 0 (deepSum (cdr L))))
((pair? (car L)) (+ (addup (car L)) (deepSum (cdr L))))
(not (list? (car L))(+ (car L) (deepSum (cdr L))))
(else (+ (car L) (deepSum (cdr L))) )
))
(deepSum '(1 (2 3 4) (5) 6 7 (8 9 10) 11))
@quang-m-nguyen
Copy link
Author

my god lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment