Skip to content

Instantly share code, notes, and snippets.

@vaishaks
Last active December 29, 2015 05:48
Show Gist options
  • Save vaishaks/7624060 to your computer and use it in GitHub Desktop.
Save vaishaks/7624060 to your computer and use it in GitHub Desktop.
It's rolling in the deeeep-reverse!
(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