Last active
December 29, 2015 05:48
-
-
Save vaishaks/7624060 to your computer and use it in GitHub Desktop.
It's rolling in the deeeep-reverse!
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
(define L '((1 2) 3 (4 (5 6)))) | |
(define deep-reverse | |
(lambda (L) | |
(if (null? L) | |
'() | |
(if (list? (car L)) | |
(append (deep-reverse (cdr L)) (list (deep-reverse (car L)))) | |
(append (deep-reverse (cdr L)) (list (car L))))))) | |
(newline) | |
(display (deep-reverse L)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment