Skip to content

Commit

Permalink
Fix needless operation (#1687)
Browse files Browse the repository at this point in the history
fixes #1585.
  • Loading branch information
Manvi-Agrawal authored Jul 11, 2024
1 parent 1ae073a commit efd6847
Show file tree
Hide file tree
Showing 27 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion samples/algorithms/DotProductViaPhaseEstimation.qs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace IterativePhaseEstimation {
return x;
}

operation ClassicalInnerProduct(theta1 : Double, theta2 : Double) : Double {
function ClassicalInnerProduct(theta1 : Double, theta2 : Double) : Double {
return Cos(theta1 / 2.0) * Cos(theta2 / 2.0) + Sin(theta1 / 2.0) * Sin(theta2 / 2.0);
}

Expand Down
2 changes: 1 addition & 1 deletion samples/language/ArithmeticOperators.qs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace MyQuantumApp {

@EntryPoint()
operation Main() : Unit {
function Main() : Unit {

// `-`, when applied to a single value on its right, negates the value.

Expand Down
14 changes: 7 additions & 7 deletions samples/language/Array.qs
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,29 @@
namespace MyQuantumApp {

@EntryPoint()
operation Main() : Int[] {
function Main() : Int[] {

// A basic Int Array literal
let intArray : Int[] = [1, 2, 3, 4];
Message($"Integer Array: {intArray} of length {Length(intArray)}");

// A basic String Array literal
let stringArray = ["a", "string", "array"];
Message($"{stringArray}");
Message($"String Array: {stringArray}");

// A new array expression creating the array `[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]`
let repeatedArray = [0, size = 10];
Message($"{repeatedArray}");
Message($"Repeated Array: {repeatedArray}");
let repeatedArray = Repeated(0, 10); // contains [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Message($"{repeatedArray}");
Message($"Repeated Array: {repeatedArray}");

// Arrays can be sliced with ranges.
let slice = intArray[1..2..4]; // contains [2,4]
Message($"{slice}");
Message($"Sliced array: {slice}");
let slice = intArray[2..-1..0]; // contains [3,2,1]
Message($"{slice}");
Message($"Sliced array: {slice}");
let slice = intArray[...]; // contains [1, 2, 3, 4];
Message($"{slice}");
Message($"Sliced array: {slice}");

return intArray;
}
Expand Down
2 changes: 1 addition & 1 deletion samples/language/BigInt.qs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace MyQuantumApp {

@EntryPoint()
operation Main() : BigInt {
function Main() : BigInt {
// Numbers can be declared in hex, octal, decimal, or binary.
let foo = 0x42L;
Message($"Hexadecimal BigInt: {foo}");
Expand Down
2 changes: 1 addition & 1 deletion samples/language/BitwiseOperators.qs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace MyQuantumApp {

@EntryPoint()
operation Main() : Unit {
function Main() : Unit {

// `~~~` performs a bitwise NOT on the bits of an integer.

Expand Down
2 changes: 1 addition & 1 deletion samples/language/Bool.qs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace MyQuantumApp {

@EntryPoint()
operation Main() : Bool {
function Main() : Bool {
// `Bool`s can be operated upon with boolean operators:
let andOp = true and true;
Message($"AND operation: {andOp}");
Expand Down
4 changes: 2 additions & 2 deletions samples/language/Comments.qs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ namespace MyQuantumApp {

/// This is a doc-comment for the `Main` operation.
@EntryPoint()
operation Main() : Result[] {
function Main() : Result[] {
// Comments can go anywhere in a program, although they typically
// preface what they refer to.
return [];
}
}
}
2 changes: 1 addition & 1 deletion samples/language/ComparisonOperators.qs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace MyQuantumApp {

@EntryPoint()
operation Main() : Unit {
function Main() : Unit {

// `==` tests if the first value is equivalent to the second value.

Expand Down
2 changes: 1 addition & 1 deletion samples/language/ConditionalBranching.qs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/// If expressions allow your code to branch, or conditionally execute parts of a Q# program.
namespace MyQuantumApp {
@EntryPoint()
operation Main() : Unit {
function Main() : Unit {
let number = 5;
// Conditionally messages "Fizz" if the `number`, in this case 5, is divisible by 3.
// Since 5 is not divisible by 3, the message "Fizz" will not be printed.
Expand Down
2 changes: 1 addition & 1 deletion samples/language/CopyAndUpdateOperator.qs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace MyQuantumApp {
newtype Pair = (first : Int, second : Int);

@EntryPoint()
operation Main() : Unit {
function Main() : Unit {
let array = [10, 11, 12, 13];
let pair = Pair(20, 21);

Expand Down
4 changes: 2 additions & 2 deletions samples/language/Double.qs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace MyQuantumApp {

@EntryPoint()
operation Main() : Double {
function Main() : Double {
// A double declared in standard notation.
let double = 0.1973269804;

Expand All @@ -19,4 +19,4 @@ namespace MyQuantumApp {

return double;
}
}
}
4 changes: 2 additions & 2 deletions samples/language/EntryPoint.qs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace MyQuantumApp {

// The Q# compiler identifies `Main` as the entry point operation because it is marked with the `@EntryPoint()` attribute.
@EntryPoint()
operation Main() : Result[] {
function Main() : Result[] {
return [];
}
}
}
2 changes: 1 addition & 1 deletion samples/language/ForLoops.qs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace MyQuantumApp {

@EntryPoint()
operation Main() : Unit {
function Main() : Unit {
// For loop over `Range`
for i in 0..5 {}

Expand Down
4 changes: 2 additions & 2 deletions samples/language/Int.qs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace MyQuantumApp {

@EntryPoint()
operation Main() : Int {
function Main() : Int {
// Numbers can be declared in hex, octal, decimal, or binary.
let foo = 0x42;
Message($"Hexadecimal: {foo}");
Expand All @@ -34,4 +34,4 @@ namespace MyQuantumApp {

return foo;
}
}
}
2 changes: 1 addition & 1 deletion samples/language/LambdaExpression.qs
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ namespace MyQuantumApp {
let incremented = Mapped(x -> x + 1, intArray);
Message($"Array after incrementing each element using Map: {incremented}");
}
}
}
2 changes: 1 addition & 1 deletion samples/language/LogicalOperators.qs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace MyQuantumApp {

@EntryPoint()
operation Main() : Unit {
function Main() : Unit {

// `and` performs the Boolean And on two Boolean values.

Expand Down
1 change: 1 addition & 0 deletions samples/language/MultiFileProject/src/Main.qs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ namespace MyQuantumApp {
let particleB = Particle(1, 1, 1);

let particleC = addParticles(particleA, particleB);
Message($"Particle C: Particle({particleC::x}, {particleC::y}, {particleC::z})")
}
}
2 changes: 1 addition & 1 deletion samples/language/PartialApplication.qs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace MyQuantumApp {
open Microsoft.Quantum.Arrays;
@EntryPoint()
operation Main() : Unit {
function Main() : Unit {
// This takes our adding function and partially applies it,
// filling the second argument with `1` and returning another
// function that takes one argument and passes it in to `Add`.
Expand Down
2 changes: 1 addition & 1 deletion samples/language/Range.qs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace MyQuantumApp {

@EntryPoint()
operation Main() : Range {
function Main() : Range {

// Ranges can be captured as local variables.

Expand Down
4 changes: 2 additions & 2 deletions samples/language/ReturnStatement.qs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/// return control flow to the callee's scope with a given value.
namespace MyQuantumApp {
@EntryPoint()
operation Main() : Unit {
function Main() : Unit {
// After the execution of the function `Returns42`, control flow
// will return to this scope.
let number42 = Returns42();
Expand All @@ -26,4 +26,4 @@ namespace MyQuantumApp {
// If a callable is annotated to return any other type besides `Unit`, then it
// must return a value of that type.
}
}
}
4 changes: 2 additions & 2 deletions samples/language/String.qs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace MyQuantumApp {

@EntryPoint()
operation Main() : String {
function Main() : String {
// Strings literals are declared with double quotes:
let myString = "Foo";

Expand All @@ -20,4 +20,4 @@ namespace MyQuantumApp {

return myString;
}
}
}
2 changes: 1 addition & 1 deletion samples/language/Ternary.qs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/// `[condition] ? [true branch] | [else branch]`
namespace MyQuantumApp {
@EntryPoint()
operation Main() : Unit {
function Main() : Unit {
let fahrenheit = -40;

// The below ternary expression sets the value of `fahrenheit` to its absolute value.
Expand Down
2 changes: 1 addition & 1 deletion samples/language/Tuple.qs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace MyQuantumApp {

@EntryPoint()
operation Main() : (Int, String) {
function Main() : (Int, String) {
// A tuple of type `String`, `Int`, and `Double`
let myTuple = ("Id", 0, 1.);
Message($"Tuple: {myTuple}");
Expand Down
2 changes: 1 addition & 1 deletion samples/language/TypeDeclarations.qs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/// in Q#. They are immutable but support a copy-and-update construct.
namespace MyQuantumApp {
@EntryPoint()
operation Main() : Unit {
function Main() : Unit {
// UDTs are defined with the `newtype` keyword.
newtype Point3d = (X : Double, Y : Double, Z : Double);

Expand Down
5 changes: 2 additions & 3 deletions samples/language/Unit.qs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
namespace MyQuantumApp {

@EntryPoint()
operation ExplicitReturn() : Unit {
// Explicitly return `Unit`.
function ExplicitReturn() : Unit {
return ();
}
operation NoReturn() : Unit {
// No return, thus implicitly returning `Unit`.
}
}
}
2 changes: 1 addition & 1 deletion samples/language/Variables.qs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Variables in Q# are immutable by default and can be shadowed.
namespace MyQuantumApp {
@EntryPoint()
operation Main() : Unit {
function Main() : Unit {
// Immutable variables are declared with the `let` keyword:
let immutableInt = 42;
Message($"Immutable Int: {immutableInt}");
Expand Down
2 changes: 1 addition & 1 deletion samples/language/WhileLoops.qs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace MyQuantumApp {

@EntryPoint()
operation Main() : Unit {
function Main() : Unit {
mutable x = 0;
while x < 3 {
set x += 1;
Expand Down

0 comments on commit efd6847

Please sign in to comment.