public
Created

  • Download Gist
rev.scm
Scheme
1 2 3 4 5 6 7 8 9
(define (rev lst)
(if (or (null? lst)
(null? (cdr lst)))
lst
(apply (lambda (x . xs)
(apply (lambda (y . ys)
(cons y (rev (cons x (rev ys)))))
(rev xs)))
lst)))

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.