# Differences

This shows you the differences between two versions of the page.

 — documentation:language_reference:functions:clone [2016/10/10 09:41] (current) 2016/10/09 21:32 Maurits W. Haverkort created 2016/10/09 21:32 Maurits W. Haverkort created Line 1: Line 1: + ====== Clone ====== + ### + Clone(//​a//​) creates a copy of the object //a//. + + 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 ==== + ​ + -- some example codedofile("​../​definitions.Quanty"​) + + Opp2 = Opp1 + Opp1.Name = "​I'​m the name of operator one" + Opp2.Name = "​I'​m the name of operator two" + print(Opp1.Name) + print(Opp2.Name) + + psi2 = psi1 + psi1.Name = "​I'​m the name of psi one" + psi2.Name = "​I'​m the name of psi two" + print(psi1.Name) + print(psi2.Name) + ​ + + ==== Result ==== + ​ + 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 //​a=Clone(b)//:​ + ### + + ==== Input ==== + ​ + dofile("​../​definitions.Quanty"​) + + Opp2 = Clone(Opp1) ​ + Opp1.Name = "​I'​m the name of operator one" + Opp2.Name = "​I'​m the name of operator two" + print(Opp1.Name) + print(Opp2.Name) + + psi2 = Clone(psi1) + psi1.Name = "​I'​m the name of psi one" + psi2.Name = "​I'​m the name of psi two" + print(psi1.Name) + print(psi2.Name) + ​ + + ==== Result ==== + ​ + 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 ==== + ​ + dofile("​../​definitions.Quanty"​) + + Opp = Opp1 + Opp2 + Opp.Name = "​I'​m the name of operator Opp and different from Opp1 and Opp2" + print(Opp1.Name) + print(Opp2.Name) + print(Opp.Name) + ​ + + ==== Result ==== + ​ + Lx + Ly + I'm the name of operator Opp and different from Opp1 and Opp2 + ​ + + ===== Table of contents ===== + {{indexmenu>​.#​1}}

Workshops

Script versions External programs Privacy

##### Tools 