The QClojure library provides a Clojure interface to quantum computing concepts. It allows us to create and manipulate quantum states, gates, and circuits in a functional programming style. QClojure can also be used to simulate quantum circuits and, by implementing backends, run them on quantum hardware.
The API is in alpha state, I expect the api to change!
Pure Functional Quantum Circuit Construction
Build quantum circuits using immutable data structures and functional composition with convenience gate functions (H, X, Y, Z, CNOT, etc.)
Comprehensive Gate Library
Support for 20+ quantum gates including single-qubit gates (Pauli, Hadamard, phase), controlled gates (CNOT, CZ, CY), rotation gates (RX, RY, RZ), and multi-qubit gates (Toffoli, Fredkin, SWAP)
Quantum Algorithm Implementations
Built-in implementations of classic quantum algorithms including Deutsch, Grover's search, Bernstein-Vazirani, and Simon's algorithms
Extensible Backend System
Protocol-based architecture allowing integration with different quantum simulators and hardware backends
Circuit Transformation & Optimization
Automatic gate decomposition and circuit transformation to match backend-supported gate sets
Local Quantum Simulator Backend
High-performance local simulator with job submission, status tracking, and statistical measurement results with configurable shot counts
OpenQASM 2.0 Integration
Bidirectional conversion between quantum circuits and OpenQASM format for interoperability with other quantum computing platforms
Visualization
Vizualization of quantum states and quantum circuits as ASCII, SVG or HTML.
Comprehensive Testing & Validation
Extensive test suite with statistical validation of quantum circuit behavior and measurement outcomes
QClojure is a library to be used in programs or interactive within the REPL.
This small example show the creation of a quantum circuit in a functional way and the execution on the simulator.
(require '[org.soulspace.qclojure.domain.quantum-circuit :as qc])
(require '[org.soulspace.qclojure.application.quantum-backend :as qb])
(require '[org.soulspace.qclojure.adapter.backend.quantum-simulator :as sim])
;; Create a simple circuit
(def circuit (-> (qc/create-circuit 2)
(qc/h-gate 0)
(qc/cnot-gate 0 1)))
;; Run the circuit on the simulator
(def simulator (sim/create-simulator))
(def result (qb/execute-circuit simulator circuit {:shots 1000}))
;; Examine the results
(:final-state result)
(:measurement-results result)
Some examples are provided in the examples folder.
QClojure is currently build with Leiningen.
Compile the code with:
lein compile
Run the test suite with:
lein test
© 2025 Ludger Solbach
Eclipse Public License 1.0 (EPL1.0)
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close