This file contains hidden or 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
[Test] | |
public static void Inlining() | |
{ | |
var length = 1000; | |
// Our Two Lambdas | |
Func<int, bool> Lt5 = x => x < 5; | |
Func<int, int, int> AddInts = (x, y) => x + y; | |
// Original expression |
This file contains hidden or 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 is a sample of the auto-generated code currently produced by Plato | |
* along with the code it was generated from. | |
* Plato and the generated code is compatible with .NET Standard 2.0 and C# 8.0 | |
*/ | |
using System; | |
namespace Plato2 | |
{ | |
/// <summary> |
This file contains hidden or 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
public partial struct Angle : INumber | |
{ | |
public double Radians { get; } | |
public const double RadiansPerRevolution = Math.PI * 2; | |
public const double DegreesPerRevolution = 360; | |
public const string InternalUnit = nameof(Radians); | |
public static Angle FromRadians(double radians) => new Angle(radians); | |
public static Angle FromRevolutions(double revolutions) => revolutions * RadiansPerRevolution; | |
public static Angle FromDegrees(double degrees) => FromRevolutions(DegreesPerRevolution / degrees); | |
public double ToDegrees() => DegreesPerRevolution * ToRevolutions(); |
This file contains hidden or 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
public class Unit { } | |
public class Kilograms : Unit { } | |
public class Seconds : Unit { } | |
public class Meters : Unit { } | |
public class Radians : Unit { } | |
public class MultiplyUnits<TUnit1, TUnit2> : Unit where TUnit1 : Unit where TUnit2 : Unit { } | |
public class DivideUnits<TUnit1, TUnit2> : Unit where TUnit1 : Unit where TUnit2 : Unit { } | |
public class Measure<T> where T : Unit | |
{ |
This file contains hidden or 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
using System; | |
namespace Plato | |
{ | |
public partial struct Float2 : IVector<float> | |
{ | |
public float X { get; } | |
public float Y { get; } | |
} |
This file contains hidden or 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
using System; | |
using Plato; | |
public class VectorAttribute : Attribute { } | |
public class ValueAttribute : Attribute { } | |
public class MeasureAttribute : Attribute { } | |
public class NumberAttribute : Attribute { } | |
public class IntervalAttribute : Attribute { } | |
namespace Plato |
This file contains hidden or 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
// Here is the basic class | |
public class Vector2_ClassNaive | |
{ | |
public double x, y; | |
} | |
// Once we decide immutability is a good thing | |
public class Vector2_ClassWithFields | |
{ | |
public readonly double x, y; |
This file contains hidden or 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
public interface IAnimator | |
{ | |
IArray<IAnimation> Animations { get; } | |
IAnimator Start(IAnimation anim); | |
IAnimator End(IAnimation anim); | |
IAnimator IsRunning(); | |
T Drive<T>(IAnimation animation, Func<T, T, float, T> lerp); | |
} |
This file contains hidden or 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
public interface IAnimationCurve | |
{ | |
double this[double t] { get; } | |
double Duration { get; } | |
} | |
public class AnimationClip<T> : IAnimationClip<T> | |
{ | |
public AnimationClip(IAnimationCurve curve, T from, T to, Func<T, T, double, T> lerp) |
This file contains hidden or 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using UnityEngine; | |
[ExecuteAlways] | |
public class PMoveTowards : MonoBehaviour | |
{ |