Deepcopy: Difference between revisions
Content added Content deleted
(Add Factor) |
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
||
Line 905: | Line 905: | ||
print(uneval(src)); |
print(uneval(src)); |
||
</lang> |
</lang> |
||
=={{header|jq}}== |
=={{header|jq}}== |
||
The distinction between "deep" and "shallow" copying is as irrelevant in a jq program as in elementary arithmetic. There is only one "equality" operator in jq and it is defined in terms of equality of values. |
The distinction between "deep" and "shallow" copying is as irrelevant in a jq program as in elementary arithmetic. There is only one "equality" operator in jq and it is defined in terms of equality of values. |
||
Line 1,417: | Line 1,418: | ||
In PARI, this is accomplished with the command <code>gcopy</code> rather than <code>shallowcopy</code> or <code>leafcopy</code>. The function takes and returns a <code>GEN</code>. See section 10.6 of the [http://pari.math.u-bordeaux.fr/pub/pari/manuals/2.5.0/libpari.pdf User's Guide to the PARI Library]. |
In PARI, this is accomplished with the command <code>gcopy</code> rather than <code>shallowcopy</code> or <code>leafcopy</code>. The function takes and returns a <code>GEN</code>. See section 10.6 of the [http://pari.math.u-bordeaux.fr/pub/pari/manuals/2.5.0/libpari.pdf User's Guide to the PARI Library]. |
||
=={{ |
=={{header|Perl}}== |
||
use [http://search.cpan.org/perldoc?Storable Storable]; <code>Storable::dclone()</code> is exactly what you are looking for. |
use [http://search.cpan.org/perldoc?Storable Storable]; <code>Storable::dclone()</code> is exactly what you are looking for. |
||
Line 1,434: | Line 1,435: | ||
print Dumper($dst); |
print Dumper($dst); |
||
</lang> |
</lang> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
Line 1,521: | Line 1,477: | ||
</pre> |
</pre> |
||
=={{ |
=={{header|PHP}}== |
||
PHP provides the <code>clone</code> operator ([http://www.php.net/manual/en/language.oop5.cloning.php docs]) for shallow copying, and allows you to hook into a magic class method called <code>__clone()</code> in your classes to do some of the lifting to create deeper copies, but this method won't create a true deep copy if you don't write the code to manage it in each of the child classes. |
PHP provides the <code>clone</code> operator ([http://www.php.net/manual/en/language.oop5.cloning.php docs]) for shallow copying, and allows you to hook into a magic class method called <code>__clone()</code> in your classes to do some of the lifting to create deeper copies, but this method won't create a true deep copy if you don't write the code to manage it in each of the child classes. |
||
Line 1,661: | Line 1,617: | ||
deepcopy: (#0=(1 . #0#) #0#) |
deepcopy: (#0=(1 . #0#) #0#) |
||
both: ((#0=(1 . #0#) #0#) (#1=(1 . #1#) #1#)) |
both: ((#0=(1 . #0#) #0#) (#1=(1 . #1#) #1#)) |
||
⚫ | |||
⚫ | |||
(formerly Perl 6) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
</pre> |
</pre> |
||