News for hackers. Stuff that matters.
Re:What would a very simple quantum program look like? by Strilanc on Wednesday June 14, 2017 @10:55AM (#14553172)
My guess is that at first it will look like existing programming languages, but with some extra commands (apply Hadamard or QFT or whatever to a register). Over time, people will find good ways to incorporate concepts like reversibility, coherent conditions, phasing, and mixing quantum/classical data deep into the language semantics.

For example, Grover's algorithm could be written like this:

    def grover_search_sample(bit_count, predicate):
        qureg = qalloc(bit_count)
        apply X to qureg
        apply H to qureg
        n = pi/4 * 2**(bit_count/2)
        for _ < n:
            if predicate(qureg):
                phase_by pi
            if all(x_axis(qureg)):
                phase_by pi
        return measure qureg

There are no comments on this comment yet.