LanQ – a quantum imperative programming language

Examples

A random number generator

Brief description of the program

The program creates a qubit (initially in maximally mixed state) which is immediately measured and the result is returned to the caller. This gives the result 0 or 1 with 50/50 probability.

Detailed description of the program

A random number generator consists of only one method from which the program is run. The program proceeds as follows:

The program

/****************************************************************************** Main method. From this method the program is run. A qubit is allocated (in maximally mixed state) and then measured in standard basis. The outcome is 0 or 1 with 50/50 probability. ******************************************************************************/
int main() {
1 qbit q;
2 q = new qbit();
3 return measure(StdBasis,q);
}

Download source code