Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #5 from wlbksy/patch-4

Update 2.27.scm
  • Loading branch information...
commit 30cfbebf4d0482d8509e8ecf9d7003b7a9ca3d24 2 parents 1cfaa5b + 9709847
@sarabander authored
Showing with 12 additions and 5 deletions.
  1. +12 −5 2.2/2.27.scm
View
17 2.2/2.27.scm
@@ -4,11 +4,18 @@
empty
(append (reverse-list (cdr lst)) (list (car lst)))))
-(define (deep-reverse lst)
- (cond ((null? lst) empty)
- ((not (pair? lst)) lst)
- (else (append (deep-reverse (cdr lst))
- (list (deep-reverse (car lst)))))))
+(define (deep-reverse1 lst)
+ (if (pair? lst)
+ (append (deep-reverse1 (cdr lst))
+ (list (deep-reverse1 (car lst))))
+ lst))
+
+(define (deep-reverse2 lst)
+ (if (pair? lst)
+ (reverse (map deep-reverse2 lst))
+ lst))
+
+(define deep-reverse deep-reverse1)
(deep-reverse '(1 2 3 4)) ; '(4 3 2 1)
Please sign in to comment.
Something went wrong with that request. Please try again.