Differences
This shows you the differences between two versions of the page.
| documentation:language_reference:functions:clone [2016/10/09 21:32] – created Maurits W. Haverkort | documentation:language_reference:functions:clone [2025/11/20 03:29] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Clone ====== | ||
| + | ### | ||
| + | Clone(// | ||
| + | |||
| + | The statement $a=b$ for objects creates two variables pointing to the same object. Changing the value of one object changes the value of the other. | ||
| + | ### | ||
| + | |||
| + | ===== Input ===== | ||
| + | |||
| + | * //a// : object of any type | ||
| + | |||
| + | ===== Output ===== | ||
| + | |||
| + | * //a'// : object of same type as //a// and an exact copy of it. | ||
| + | |||
| + | ===== Example a=b ===== | ||
| + | |||
| + | ### | ||
| + | A small example showing the effect on //b// after changing //a// when //a=b//: | ||
| + | ### | ||
| + | |||
| + | ==== Input ==== | ||
| + | <code Quanty CloneNot.Quanty> | ||
| + | -- some example codedofile(" | ||
| + | |||
| + | Opp2 = Opp1 | ||
| + | Opp1.Name = " | ||
| + | Opp2.Name = " | ||
| + | print(Opp1.Name) | ||
| + | print(Opp2.Name) | ||
| + | |||
| + | psi2 = psi1 | ||
| + | psi1.Name = " | ||
| + | psi2.Name = " | ||
| + | print(psi1.Name) | ||
| + | print(psi2.Name) | ||
| + | </ | ||
| + | |||
| + | ==== Result ==== | ||
| + | <file Quanty_Output CloneNot.out> | ||
| + | I'm the name of operator two | ||
| + | I'm the name of operator two | ||
| + | I'm the name of psi two | ||
| + | I'm the name of psi two | ||
| + | </ | ||
| + | |||
| + | ===== Example a=Clone(b) ===== | ||
| + | |||
| + | ### | ||
| + | A small example showing // | ||
| + | ### | ||
| + | |||
| + | ==== Input ==== | ||
| + | <code Quanty Clone.Quanty> | ||
| + | dofile(" | ||
| + | |||
| + | Opp2 = Clone(Opp1) | ||
| + | Opp1.Name = " | ||
| + | Opp2.Name = " | ||
| + | print(Opp1.Name) | ||
| + | print(Opp2.Name) | ||
| + | |||
| + | psi2 = Clone(psi1) | ||
| + | psi1.Name = " | ||
| + | psi2.Name = " | ||
| + | print(psi1.Name) | ||
| + | print(psi2.Name) | ||
| + | </ | ||
| + | |||
| + | ==== Result ==== | ||
| + | <file Quanty_Output Clone.out> | ||
| + | I'm the name of operator one | ||
| + | I'm the name of operator two | ||
| + | I'm the name of psi one | ||
| + | I'm the name of psi two | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== Example a=a+b ===== | ||
| + | |||
| + | ### | ||
| + | A small example showing that operations acting on objects lead to cloning the object: | ||
| + | ### | ||
| + | |||
| + | ==== Input ==== | ||
| + | <code Quanty CloneAuto.Quanty> | ||
| + | dofile(" | ||
| + | |||
| + | Opp = Opp1 + Opp2 | ||
| + | Opp.Name = " | ||
| + | print(Opp1.Name) | ||
| + | print(Opp2.Name) | ||
| + | print(Opp.Name) | ||
| + | </ | ||
| + | |||
| + | ==== Result ==== | ||
| + | <file Quanty_Output CloneAuto.out> | ||
| + | Lx | ||
| + | Ly | ||
| + | I'm the name of operator Opp and different from Opp1 and Opp2 | ||
| + | </ | ||
| + | |||
| + | ===== Table of contents ===== | ||
| + | {{indexmenu> | ||