| page_type | sample | |
|---|---|---|
| languages |
|
|
| products |
|
|
| description | This sample uses the `Microsoft.Quantum.AutoSubstitution` NuGet package to provide alternative operations based on the simulator that is used. |
The Microsoft.Quantum.AutoSubstitution NuGet package offers an attribute @SubstitutableOnTarget that lets you replace one operation with another when using a particular simulator. For instance, decorating the operation Op with @SubstitutableOnTarget("AltOp", "Sim") lets the compiler perform a rewrite step that can link an operation Op to a set of pairs of an alternative operations AltOp and a simulator Sim, such that AltOp is executed as a replacement for Op when being invoked in Sim.
This auto substitution blog post in the Q# blog describes this sample in more detail.
First, run
dotnet runand you should see Quantum version as output, but when running
dotnet run -- -s ToffoliSimulatorthe program prints Classical version instead, since the alternative operation
is executed.
- AutoSubstitution.qs: The main Q# example code implementing quantum operations for this sample.
- AutoSubstitution.csproj: Main Q# project for the sample.