Skip to content

Instantly share code, notes, and snippets.

Avatar

Abel Braaksma abelbraaksma

View GitHub Profile
@odinhaus
odinhaus / FastCopy.cs
Created Nov 16, 2016
Fast C# Byte[] Copier Using Cpblk IL Instruction
View FastCopy.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Tests
@gusty
gusty / polyvariadic.fsx
Last active Aug 16, 2020
Polyvariadic functions in F#
View polyvariadic.fsx
// Unfortunatelly it stopped working in F# 4.1 after this PR https://github.com/Microsoft/visualfsharp/pull/1650
// Will ask to revert it
type FoldArgs<'t> = FoldArgs of ('t -> 't -> 't)
let inline foldArgs f (x:'t) (y:'t) :'rest = (FoldArgs f $ Unchecked.defaultof<'rest>) x y
type FoldArgs<'t> with
static member inline ($) (FoldArgs f, _:'t-> 'rest) = fun (a:'t) -> f a >> foldArgs f
static member ($) (FoldArgs f, _:'t ) = f
You can’t perform that action at this time.