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
using System.Linq; | |
public static class Index | |
{ | |
public static Index<TKey, TValue> Create<TKey, TValue>() | |
where TKey : notnull | |
{ | |
var keyMap = new Dictionary<TKey, HashSet<TValue>>(); | |
Action<TKey, TValue> add = (key, value) => |
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
using Nessos.Effects; | |
using Nessos.Effects.Handlers; | |
public class ConsolePrintEffect : Effect | |
{ | |
public string? Message { init; get; } | |
} |
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
let dropWhile : ('a -> bool) -> list<'a> -> list<'a> = fun pred xs -> | |
let (_, ys) = List.foldBack (fun x (xs, ys) -> let xs' = x :: xs in if pred x then xs', ys else xs', xs') xs ([], []) | |
ys | |
// example 1 | |
[1..10] |> dropWhile (fun x -> x <= 5) // [6..10] | |
// example 2 | |
[1..10] |> dropWhile (fun x -> false) // [1..10] |
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
type Append<T, TArray> = TArray extends [infer TCurrent, ...infer Rest] ? | |
TCurrent extends any[] ? [[T, ...TCurrent], ...Append<T, Rest>] : never | |
: [] | |
type PowerSet<TArray extends any[]> = | |
TArray extends [infer TCurrent, ...infer Rest] ? [...Append<TCurrent, PowerSet<Rest>>, ...PowerSet<Rest>] : [[]] | |
type Test = PowerSet<[1, 2, 3]> // [[1, 2, 3], [1, 2], [1, 3], [1], [2, 3], [2], [3], []] |
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
using System; | |
public class C { | |
public void M() { | |
Func<Func<dynamic, dynamic>, dynamic> fd = x => x; | |
dynamic Y = fd(f => fd(x => f(fd(y => x(x)(y))))(fd(x => f(fd(y => x(x)(y)))))); | |
Y(fd(f => fd(x => f(x))))(42); | |
} | |
} |
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
class Program | |
{ | |
class Node | |
{ | |
public int Id; | |
public Node Parent; | |
} | |
class TreeNode | |
{ |
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
public class Subs : ExpressionVisitor | |
{ | |
private Dictionary<ParameterExpression, Expression> env; | |
public Subs(Dictionary<ParameterExpression, Expression> env) | |
{ | |
this.env = env; | |
} | |
protected override Expression VisitParameter(ParameterExpression node) | |
{ |
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
public interface IBoolExpr { } | |
public class And : IBoolExpr | |
{ | |
public IBoolExpr Left { get; set; } | |
public IBoolExpr Right { get; set; } | |
public void Deconstruct(out IBoolExpr left, out IBoolExpr right) | |
{ | |
left = Left; | |
right = Right; | |
} |
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
let f (x0 : int []) = | |
let x1 = ref 0 | |
let x2 = ref true | |
let x3 = ref false | |
let x4 = ref 0 | |
let x5 = ref 0 | |
let x6 = ref true | |
let x7 = ref true | |
let x8 = ref 0 | |
let x9 = ref 0 |
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
let f (x0 : int[]) (x1 : int[]) = | |
let x2 = ref 0 | |
let x3 = ref true | |
let x4 = ref false | |
let x5 = ref 0 | |
let x6 = ref 0 | |
let x7 = ref true | |
let x8 = ref true | |
let x9 = ref 0 | |
let x10 = ref 0 |
NewerOlder