(define (square-list-bug1 items) (define (iter things answer) (if (null? things) answer (iter (cdr things) (cons (square (car things)) answer)))) (iter items '())) ; 1 ]=> (square-list-bug1 '(1 2 3 4 5)) ; ; ;Value: (25 16 9 4 1) ; This version of square list builds answer starting from the first item and ; appending following results to the front of answer. This causes the result ; to be reversed. (define (square-list-bug2 items) (define (iter things answer) (if (null? things) answer (iter (cdr things) (cons answer (square (car things)))))) (iter items '())) ; ; 1 ]=> (square-list-bug2 '(1 2 3 4 5)) ; ; ;Value: (((((() . 1) . 4) . 9) . 16) . 25) ; Because this version prepends the current partial answer - which is a list - ; to the front of the next partial answer, the final result will have a nested ; list as an element rather the being a list of numbers. The only input this ; function is correct for is the empty list.