;#!/usr/bin/racket
;#lang scheme
(define (reverse items)
(define (iter xs result)
(if (null? xs)
result
(iter (cdr xs) (cons (car xs) result))))
(iter items '()))
(define (deep-reverse items)
(if (not (pair? items))
items
(reverse (map deep-reverse items))))
; ((1 2) (3 4))
(define x (list (list 1 2) (list 3 4)))
;(display x)
;(newline)
;(display (reverse x))
;(newline)
; (deep-reverse ((1 2) (3 4)) )
; (reverse (map deep-reverse ((1 2) (3 4)) ))
; (reverse (reverse (map deep-reverse (1 2) )))
; (reverse (reverse (map
(display (deep-reverse x))
(newline)
OyMhL3Vzci9iaW4vcmFja2V0CjsjbGFuZyBzY2hlbWUKCihkZWZpbmUgKHJldmVyc2UgaXRlbXMpCiAgICAgICAgKGRlZmluZSAoaXRlciB4cyByZXN1bHQpCiAgICAgICAgICAgICAgICAoaWYgKG51bGw/IHhzKQogICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQKICAgICAgICAgICAgICAgICAgICAgICAgKGl0ZXIgKGNkciB4cykgKGNvbnMgKGNhciB4cykgcmVzdWx0KSkpKQogICAgICAgIChpdGVyIGl0ZW1zICcoKSkpCgooZGVmaW5lIChkZWVwLXJldmVyc2UgaXRlbXMpCiAgICAgICAgKGlmIChub3QgKHBhaXI/IGl0ZW1zKSkKICAgICAgICAgICAgICAgIGl0ZW1zCiAgICAgICAgICAgICAgICAocmV2ZXJzZSAobWFwIGRlZXAtcmV2ZXJzZSBpdGVtcykpKSkKCjsgKCgxIDIpICgzIDQpKQooZGVmaW5lIHggKGxpc3QgKGxpc3QgMSAyKSAobGlzdCAzIDQpKSkKCjsoZGlzcGxheSB4KQo7KG5ld2xpbmUpCgo7KGRpc3BsYXkgKHJldmVyc2UgeCkpCjsobmV3bGluZSkKCjsgKGRlZXAtcmV2ZXJzZSAoKDEgMikgKDMgNCkpICkKOyAocmV2ZXJzZSAobWFwIGRlZXAtcmV2ZXJzZSAoKDEgMikgKDMgNCkpICkpCjsgKHJldmVyc2UgKHJldmVyc2UgKG1hcCBkZWVwLXJldmVyc2UgKDEgMikgKSkpCjsgKHJldmVyc2UgKHJldmVyc2UgKG1hcAooZGlzcGxheSAoZGVlcC1yZXZlcnNlIHgpKQoobmV3bGluZSkK