This commit is contained in:
Ingy döt Net 2013-06-05 21:47:54 +00:00
parent 1f1ad49427
commit 6f050a029e
2496 changed files with 37609 additions and 3031 deletions

View file

@ -0,0 +1,14 @@
#lang racket
(define (deepcopy x)
;; make sure that all sharings are shown
(parameterize ([print-graph #t]) (read (open-input-string (format "~s" x)))))
(define (try x)
;; use the same setting to see that it worked
(parameterize ([print-graph #t])
(printf "original: ~s\n" x)
(printf "deepcopy: ~s\n" (deepcopy x))
;; print both also, which shows that they are indeed different
(printf "both: ~s\n" (list x (deepcopy x)))))
(try (shared ([x (cons 1 x)]) (list x x)))