Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
14
Task/Deepcopy/Racket/deepcopy.rkt
Normal file
14
Task/Deepcopy/Racket/deepcopy.rkt
Normal 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)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue