Defining variables in Silq
Let's see how to assign data to a variable in the Silq language. Variable assignment is one of the fundamental techniques used in programming to store data in memory and then access it as and when required in a particular program.
The symbols that are used to do variable assignment are := (colon and equals symbol) and : (colon symbol), which are used to assign a particular data type to the variable. Let's see an example of this in the following code:
x:=H(x);
In the preceding code, you can see that H(x) is assigned to the x variable, which is a qubit, and H(x) is the Hadamard gate applied to the x qubit.
Now, if you want to make x a qubit, then you have to assign it the Boolean data type. This is shown in the next code block:
x:=0:;
This means that you have defined x as the 0 qubit and have made it of the quantum Boolean type. To make x of the classical type, you have to use the ! Silq annotation to distinguish quantum and classical...
