quipper-demos-0.9.0.0: Quipper/Demos/Example.hs
import Quipper
import Prelude hiding (and)
example1 :: (Qubit, Qubit, Qubit) -> Circ (Qubit, Qubit, Qubit)
example1 (a,b,c) = do
qnot_at a `controlled` [b, c]
hadamard b `controlled` [a]
qnot_at a `controlled` [b, c]
hadamard c `controlled` [a]
return (a,b,c)
example2 :: Qubit -> Qubit -> Qubit -> Qubit -> Circ ()
example2 h a b c = do
qnot_at c `controlled` [a, b]
hadamard h `controlled` [c]
qnot_at c `controlled` [a, b]
example3 :: Qubit -> Qubit -> Qubit -> Circ ()
example3 h a b = do
with_ancilla $ \c -> do
qnot_at c `controlled` [a, b]
hadamard h `controlled` [c]
qnot_at c `controlled` [a, b]
example4 :: (Qubit, Qubit, Qubit, Qubit) -> Circ (Qubit, Qubit, Qubit, Qubit)
example4 (a,b,c,d) = do
qnot_at a
qnot_at b
with_controls (c .&&. d) $ do
qnot_at a
qnot_at b
qnot_at c
return (a,b,c,d)
main =
print_simple Preview example4