#lang racket ; tail recursion is very cheap, structure your code to use it when ; possible. You may have to introduce a helper function ; notice how the stack never gets deeper than two calls (define lreverse-acc (lambda (L) (lreverse-r L '())) ) ; the recursor helper function accumulates the final result in out-list ; out-list is called an accumulator ; notice how the stack never gets deeper than two calls (define lreverse-r (lambda (in-list out-list) (if (null? in-list) out-list (lreverse-r (rest in-list) (cons (first in-list) out-list)) ) ) ) (lreverse-r '() '()) (lreverse-r '(1) '()) (lreverse-r '(1 2 3 4) '()) (lreverse-acc '(1 2 3 4))