Quantum loop programs