Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1 @@
(mapcar copy List)

View file

@ -0,0 +1,4 @@
(de deepCopy (X)
(if (atom X)
X
(cons (deepCopy (car X)) (deepCopy (cdr X))) ) )

View file

@ -0,0 +1,25 @@
: (setq A '((a . b) (c d e) f g . e))
-> ((a . b) (c d e) f g . e)
: (setq B (deepCopy A))
-> ((a . b) (c d e) f g . e)
: A
-> ((a . b) (c d e) f g . e)
: B
-> ((a . b) (c d e) f g . e)
: (= A B)
-> T # A and its copy B are structure-equal
: (== A B)
-> NIL # but they are not identical (pointer-equal)
: (cadr A)
-> (c d e)
: (cadr B)
-> (c d e)
: (== (cadr A) (cadr B))
-> NIL # The same holds for sub-structures

View file

@ -0,0 +1,11 @@
(de deepCopy (X)
(let Mark NIL
(recur (X)
(cond
((atom X) X)
((asoq X Mark) (cdr @))
(T
(prog1 (cons)
(push 'Mark (cons X @))
(set @ (recurse (car X)))
(con @ (recurse (cdr X))) ) ) ) ) ) )

View file

@ -0,0 +1,12 @@
: (setq A '(a b .) B (deepCopy A))
-> (a b .)
: A
-> (a b .)
: B
-> (a b .)
: (= A B)
-> T # A and its copy B are structure-equal
: (== A B)
-> NIL # but they are not identical (pointer-equal)