Expected results for test: P3-56.pl460 P3-56.pl460 : ;; insert_last will insert a value into a list as the last element of the list. ;; The formal arguments should be the value to be inserted into the list and the ;; list. (define (insert_last myvalue mylist) (if (list? mylist) (if (null? mylist) (cons myvalue mylist) (cons (car mylist) (insert_last myvalue (cdr mylist))) ) "insert_last requires a list argument" ) ) ;; list_reverse will reverse the elements of a list. The formal argument should ;; be a list. (define (list_reverse ls) (if (list? ls) (if (null? ls) '() (insert_last (car ls) (list_reverse (cdr ls))) ) "list_reverse requires a list argument" ) ) (define (main) (display (list_reverse '(a 1 b 2 c 3 d 4 e))) (newline) (display (list_reverse '(a 1 (b 2 c) 3 (d 4) e))) (newline) ) (main) Input file: P3-56.pl460 0 errors found in input file P3-56.cpp : // Autogenerated PL460 to C++ Code // File: P3-56.cpp #include #include "Object.h" using namespace std; Object insert_last (Object myvalue, Object mylist) { Object __RetVal; if (listp (mylist)) { if (nullp (mylist)) { __RetVal = listop ("cons", myvalue, mylist); } else { __RetVal = listop ("cons", listop ("car", mylist), insert_last(myvalue, listop ("cdr", mylist))); } } else { __RetVal = Object("insert_last requires a list argument"); } return __RetVal; } Object list_reverse (Object ls) { Object __RetVal; if (listp (ls)) { if (nullp (ls)) { __RetVal = Object("()"); } else { __RetVal = insert_last(listop ("car", ls), list_reverse(listop ("cdr", ls))); } } else { __RetVal = Object("list_reverse requires a list argument"); } return __RetVal; } int main () { Object __RetVal; cout << list_reverse(Object("(a 1 b 2 c 3 d 4 e )")); cout << endl; cout << list_reverse(Object("(a 1 (b 2 c ) 3 (d 4 ) e )")); cout << endl; return 0; } PL460 program output: (e 4 d 3 c 2 b 1 a) (e (d 4) 3 (b 2 c) 1 a) C++ program output: (e 4 d 3 c 2 b 1 a) (e (d 4) 3 (b 2 c) 1 a) Differences: < pl460 | cpp > (e 4 d 3 c 2 b 1 a) (e 4 d 3 c 2 b 1 a) (e (d 4) 3 (b 2 c) 1 a) (e (d 4) 3 (b 2 c) 1 a)