-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #695 from lucabol/master
Add a source generator for a Maths language to the samples
- Loading branch information
Showing
5 changed files
with
502 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
AreaSquare(l) = pow(l, 2) | ||
AreaRectangle(w, h) = w * h | ||
AreaCircle(r) = pi * r * r | ||
Quadratic(a, b, c) = {-b + sqrt(pow(b,2) - 4 * a * c)} / (2 * a) | ||
|
||
GoldenRatio = 1.61803 | ||
GoldHarm(n) = GoldenRatio + 1 * ∑(i, 1, n, 1 / i) | ||
|
||
D(x', x'', y', y'') = sqrt(pow([x'-x''],2) + pow([y'-y''], 2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
samples/CSharp/SourceGenerators/GeneratedDemo/UseMathsGenerator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using static System.Console; | ||
using Maths; | ||
|
||
namespace GeneratedDemo | ||
{ | ||
public static class UseMathsGenerator | ||
{ | ||
public static void Run() | ||
{ | ||
WriteLine($"The area of a (10, 5) rectangle is: {Formulas.AreaRectangle(10, 5)}"); | ||
WriteLine($"The area of a (10) square is: {Formulas.AreaSquare(10)}"); | ||
WriteLine($"The GoldHarmon of 3 is: {Formulas.GoldHarm(3)}"); | ||
} | ||
} | ||
} |
Oops, something went wrong.