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
#nowarn "3535" | |
open System.Numerics | |
module rec Arrays = | |
type IArray<'T> = | |
abstract Item: int -> 'T with get | |
type IOperation<'T> = | |
static abstract Invoke: 'T * 'T -> 'T |
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
Player CreatePlayer() | |
{ | |
IEnumerable<int> ReadPlayerDeck() | |
{ | |
var x = int.Parse(Console.ReadLine()!); | |
for (var i = 0; i <= x; i++) | |
{ | |
yield return Console.ReadLine()!.Trim('D', 'H', 'C', 'S') switch | |
{ | |
['J', ..] => 11, |
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
T[] Concat<T>(IEnumerable<T> first, params IEnumerable<T>[] others) | |
{ | |
foreach (var other in others) | |
first = first.Concat(other); | |
return first.ToArray(); | |
} | |
Player CreatePlayer() | |
{ | |
IEnumerable<int> ReadPlayerDeck() |
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
open System | |
type Player = { | |
Deck: int list | |
WarStack: int list | |
} | |
let createPlayer() = | |
let deck = seq { | |
let n = int(Console.In.ReadLine()) |
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
module Gists.FSharp.SilkNetSdl | |
open System.Runtime.CompilerServices | |
open Gists.CSharp | |
open Microsoft.FSharp.NativeInterop | |
open Silk.NET.SDL | |
open Silk.NET.Maths | |
let fillRect (api: Sdl) (screen: nativeptr<Surface>) color = | |
let nullref = &Unsafe.NullRef<Rectangle<int>>() |
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; | |
using System.Linq; | |
using System.Reflection; | |
using Microsoft.Extensions.DependencyInjection; | |
namespace AutoInject | |
{ | |
public enum InjectType | |
{ | |
Singleton, |
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
module Benchmarks.FSharp.FuncsVsFSharpFuncs | |
open System | |
open BenchmarkDotNet.Attributes | |
module List = | |
let iteri2WithFunc (func: Func<int, 'a, 'a, 'a>) list1 list2 = | |
let rec iteri2Internal i list1 list2 = | |
match list1, list2 with | |
| h1 :: t1, h2 :: t2 -> |
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
module Benchmarks.FSharp.FormatBenchmark | |
#nowarn "20" | |
module Printer = | |
open System | |
open TypeShape.Core | |
open TypeShape.Core.Utils | |
// Generic pretty printer with recursive type support | |
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
module Benchmarks.FSharp.FormatBenchmark | |
open System | |
open System.Text | |
open BenchmarkDotNet.Attributes | |
open BenchmarkDotNet.Jobs | |
let ignoreFormatting = String.Equals("abc", "ABC", StringComparison.OrdinalIgnoreCase) | |
let inline ignoreAndReturnDefault _ = Unchecked.defaultof<'b> |
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 IOptionalParameter = | |
abstract member Do: count: int * [<Optional; DefaultParameterValue 10>] length : int -> unit | |
type OptionalParameter() = | |
member _.Do(count, [<Optional; DefaultParameterValue 10>]length) = printf "%i" (count + length) | |
interface IOptionalParameter with | |
member this.Do(count, length) = | |
this.Do(count, length) | |
let op1 = OptionalParameter().Do 12 |