Skip to content

Instantly share code, notes, and snippets.

#r "nuget: Flips,2.4.7"
open Flips
open Flips.Types
let x =
DecisionBuilder "x" {
for index in 1..5 ->
Continuous (0.0, infinity)
} |> Map
[<Measure>] type Chicken
[<Measure>] type Cow
type Arr<[<Measure>] 'Measure>(v: array<_>) =
let values = v
member _.Item
with inline get (i: int<'Measure>) =
v.[int i]
// Validating benchmarks:
// ***** BenchmarkRunner: Start *****
// ***** Found 2 benchmark(s) in total *****
// ***** Building 1 exe(s) in Parallel: Start *****
// start dotnet restore /p:UseSharedCompilation=false /p:BuildInParallel=false /m:1 /p:Deterministic=true /p:Optimize=true in C:\Users\matth\source\repos\TypedArrayIndexing\bin\Release\net6.0\af583c40-01ab-4113-bd10-b7f8ac106bac
// command took 1s and exited with 0
// start dotnet build -c Release --no-restore /p:UseSharedCompilation=false /p:BuildInParallel=false /m:1 /p:Deterministic=true /p:Optimize=true in C:\Users\matth\source\repos\TypedArrayIndexing\bin\Release\net6.0\af583c40-01ab-4113-bd10-b7f8ac106bac
// command took 0.9s and exited with 1
// start dotnet build -c Release --no-restore --no-dependencies /p:UseSharedCompilation=false /p:BuildInParallel=false /m:1 /p:Deterministic=true /p:Optimize=true in C:\Users\matth\source\repos\TypedArrayIndexing\bin\Release\net6.0\af583c40-01ab-4113-bd10-b7f8ac106bac
// command took 1.62s and exite
open System
open BenchmarkDotNet.Attributes
open BenchmarkDotNet.Running
open BenchmarkDotNet.Diagnosers
[<HardwareCounters(HardwareCounter.BranchMispredictions, HardwareCounter.CacheMisses)>]
[<DisassemblyDiagnoser(printSource = true, exportHtml = true)>]
type Benchmarks () =
let rng = Random 123
[<Measure>] type Chicken
[<Measure>] type Cow
type Arr<[<Measure>] 'Measure>(v: array<'T>) =
member _.Item
with get (i: int<'Measure>) =
v.[int i]
@matthewcrews
matthewcrews / PrivateUoM.fsx
Created April 30, 2022 21:28
Define a UoM which can only be created from a "constructor"
module Units =
[<Measure>] type private Chicken
module Chicken =
let create x =
if x < 0 then
invalidArg (nameof x) "Cannot have a Chicken <0"
[<Struct;IsByRefLike>]
type StackStack<'T>(values: Span<'T>) =
[<DefaultValue>] val mutable private Count : int
member s.Push v =
if s.Count < values.Length then
values[s.Count] <- v
s.Count <- s.Count + 1
else
failwith "Exceeded capacity of StackStack"
open System
open System.Collections
open System.Collections.Generic
module private Helpers =
let inline computeBucketAndMask (itemKey: int<'Item>) itemCount =
if (uint itemKey) >= (uint itemCount) then
raise (IndexOutOfRangeException (nameof itemKey))
@matthewcrews
matthewcrews / settings.json
Created September 1, 2022 21:23
VS Code Settings
{
"workbench.colorTheme": "GDScript",
"editor.tokenColorCustomizations": {
"[Dracula Soft]": {
"textMateRules": [
{
"scope": "keyword.fsharp",
"settings": {
"foreground": "#65d6ff8b",
}

Tractor: A CLR Language for Numerical Computation

The original intention of the dotnet was to provide a runtime for many programming languages to run on. Two factors have kept that vision from fruition: tying .NET Framework to Windows and the dominance of C#.

Dotnet can now run on almost any modern system. A significant push has been made toward performance features for C# and the CLR. The intention is to close the performance gap between systems-level programming languages (C, C++, Rust, Zig, and Odin, to name a few) and what can be achieved on the dotnet platform.

A general-purpose language like C# and F# must support

Guiding Principles