Crates.io | qprime |
lib.rs | qprime |
version | 0.0.6 |
source | src |
created_at | 2024-10-22 18:54:01.231409 |
updated_at | 2024-10-24 17:54:35.832979 |
description | An experimental programming language for quantum and weather calculations/applications. |
homepage | |
repository | https://github.com/zanderlewis/qprime |
max_upload_size | |
id | 1419048 |
size | 90,413 |
Q' (Q Prime) is an experimental programming language for quantum and weather calculations, formally known as Weather.
Q' is a programming language for quantum and weather calculations. It is designed to be simple and easy to use, while still being powerful enough to perform complex calculations. The language is inspired by FORTRAN and Q#, but aims to be more modern and user-friendly.
Q' is still in development and is not yet ready for general use. However, you can try it out by cloning the repository and running the code in the src
directory using Cargo:
git clone https://github.com/zanderlewis/qprime
cd qprime
cargo run script.qpr
or, you can install via Cargo:
cargo install qprime
To use Q', write your code in a file with a .qpr
extension and run it using the Q' interpreter. For example, to run a script called script.qpr
, you would use the following command:
cargo run script.qpr
or, if you installed Q' via Cargo:
qprime script.qpr
The syntax of Q' is similar to that of Python, with some improvements for quantum/weather applications. Here is an example:
# Assign values to variables
temp = 0
humidity = 7
fahrenheit = 86
celsius = 30
# Calculate and print the dew point
dew_point = dewpoint(temp, humidity)
print("Dew Point: ")
print(dew_point)
# Convert Fahrenheit to Celsius and print the result
celsius_converted = ftoc(fahrenheit)
print("Fahrenheit to Celsius: ")
print(celsius_converted)
# Convert Celsius to Fahrenheit and print the result
fahrenheit_converted = ctof(celsius)
print("Celsius to Fahrenheit: ")
print(fahrenheit_converted)
# Initialize 2 qubits
q1 = qubit(0, 1) # State of |0>, 1 qubit
q2 = qubit(1, 1) # State of |1>, 1 qubit
# Apply Hadamard gate to qubit q1
h = hadamard(q1)
# Apply Pauli-X gate to qubit q1
x = pauli_x(q1)
# Apply CNOT gate to qubits q1 and q2
_cnot = cnot(q1, q2)
# Measure the CNOT gate
m = measure(_cnot)
# Print the result of the measurement
print(m)
print(q1)
print(q2)
script.qpr and quantum.qpr are good places to start.
Contributions are welcome! Please open an issue or submit a pull request if you would like to contribute to Q'.
Q' is licensed under the Apache-2.0 License. See LICENSE for more information.