Skip to content

Instantly share code, notes, and snippets.

View En3Tho's full-sized avatar

Igor Bagdamyan En3Tho

  • 11:11 (UTC +03:00)
View GitHub Profile
@En3Tho
En3Tho / Arrays.fs
Last active January 23, 2023 17:26
#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
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,
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()
@En3Tho
En3Tho / winamax.fs
Last active October 10, 2022 09:48
open System
type Player = {
Deck: int list
WarStack: int list
}
let createPlayer() =
let deck = seq {
let n = int(Console.In.ReadLine())
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>>()
using System;
using System.Linq;
using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
namespace AutoInject
{
public enum InjectType
{
Singleton,
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 ->
module Benchmarks.FSharp.FormatBenchmark
#nowarn "20"
module Printer =
open System
open TypeShape.Core
open TypeShape.Core.Utils
// Generic pretty printer with recursive type support
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>
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