Skip to content

Instantly share code, notes, and snippets.

View akarpov89's full-sized avatar

Andrew Karpov akarpov89

  • JetBrains
View GitHub Profile
@akarpov89
akarpov89 / InterpolatedParsing.cs
Created October 1, 2021 14:58
Interpolated parsing technique
using System.Runtime.CompilerServices;
using static ParsingExtensions;
string input = "Name: Andrew; Age: 31";
string? name = null;
int age = 0;
if (input.TryParse($"Name: {Placeholder(ref name)}; Age: {Placeholder(ref age)}"))
{
@akarpov89
akarpov89 / Program.cs
Created March 16, 2020 09:35
Summer Internship 2020 Task
using System;
using System.Text;
namespace InternshipTask
{
public interface IExpression
{
T Accept<T>(IVisitor<T> visitor);
}
@akarpov89
akarpov89 / RangeStub.cs
Created December 3, 2018 14:27
Index and Range API stub
namespace System
{
public readonly partial struct Index : System.IEquatable<System.Index>
{
private readonly int _dummyPrimitive;
public Index(int value, bool fromEnd) { throw null; }
public int Value { get { throw null; } }
public bool FromEnd { get { throw null; } }
public override bool Equals(object value) { throw null; }
public bool Equals(Index other) { throw null; }

Keybase proof

I hereby claim:

  • I am akarpov89 on github.
  • I am akarpov89 (https://keybase.io/akarpov89) on keybase.
  • I have a public key ASBfra_qWZxw2BzvU5jt7zF3ocnAIbAGc3Pm-SauFPnO5go

To claim this, I am signing this object:

@akarpov89
akarpov89 / fact.cpp
Last active August 29, 2015 14:07
Infinite recursion during compile expansion
template <unsigned n>
unsigned fact()
{
if (n == 0)
return 1;
// return n * fact<n - 1>(); <-- not compiles, infinite recursion
return n * fact<n - (n ? 1 : 0)>(); // OK
}