Skip to content

Instantly share code, notes, and snippets.

View manofstick's full-sized avatar

Paul Westcott manofstick

  • Kaiser Trading Group
  • Melbourne, Australia
View GitHub Profile
@manofstick
manofstick / filter.fs
Created June 21, 2023 05:01
FSharp filter
View filter.fs
[<System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)>]
let invalidStateOfEmptyList () = raise (System.InvalidProgramException "list can not be empty")
/// optimized filter if filtered items are all at the end of the list then that list is returned
/// the function entryToFilterToFreshConsTail was the original version of filter, and is used
/// in the case of there being multiple segments in the data
let filter predicate originalList =
let rec entryToFilterToFreshConsTail lst =
match lst with
| [] -> []
@manofstick
manofstick / matrix.cs
Created April 5, 2023 04:59
Matrix Mult
View matrix.cs
class Matrix<T>
{
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
public static void InnerLoop4_3(Span<Vector<T>> ARowVector0, Span<Vector<T>> ARowVector1, Span<Vector<T>> ARowVector2, Span<Vector<T>> ARowVector3, Span<Vector<T>> BTRowVector0, Span<Vector<T>> BTRowVector1, Span<Vector<T>> BTRowVector2, out Tmp4_3 tmp)
{
var tmpVector0_0 = Vector<T>.Zero; var tmpVector0_1 = Vector<T>.Zero; var tmpVector0_2 = Vector<T>.Zero;
var tmpVector1_0 = Vector<T>.Zero; var tmpVector1_1 = Vector<T>.Zero; var tmpVector1_2 = Vector<T>.Zero;
var tmpVector2_0 = Vector<T>.Zero; var tmpVector2_1 = Vector<T>.Zero; var tmpVector2_2 = Vector<T>.Zero;
var tmpVector3_0 = Vector<T>.Zero; var tmpVector3_1 = Vector<T>.Zero; var tmpVector3_2 = Vector<T>.Zero;
View chainlinq2.cs
using System;
using System.Linq;
using System.Diagnostics;
namespace ConsoleApplication2
{
class Program
{
const string source = "https://github.com/dwyl/english-words/raw/042fb7abca733b186f150dcce85023048e84705f/words.txt";
const string filename = "lotsofwords.txt";
@manofstick
manofstick / chainlinq1.cs
Created December 22, 2018 05:45
LinqOptimizer's CartLinq
View chainlinq1.cs
using System;
using System.Diagnostics;
#if manofstick_test_chainlinq
using System.ChainLinq;
#else
using System.Linq;
#endif
class Program
{
@manofstick
manofstick / take2.cs
Last active November 22, 2018 22:59
take ii!
View take2.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace ConsoleApp95
{
class Node
{
@manofstick
manofstick / take.cs
Created November 22, 2018 20:32
An alternative take on things...
View take.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace ConsoleApp95
{
class Node
{
View 5360e.fs
open System
open System.Diagnostics
for i = 1 to 5 do
let data =
let r = Random i
Array.init 2500 (fun _ ->
Seq.init (r.Next 50) (fun _ -> r.Next 3)
|> Set.ofSeq)
@manofstick
manofstick / driver.ps1
Last active July 28, 2018 05:53
Battle Royale - 3: Batch creation
View driver.ps1
$platforms = @("--platform:x86","--platform:x64")
$conditionals = @("--define:IMMUTABLEDICTIONARY", "")
#$platforms = @("--platform:x86")
#$conditionals = @("")
For ($pIdx=0; $pIdx -lt $platforms.Length; $pIdx++) {
$platform = $platforms[$pIdx]
For ($cIdx=0; $cIdx -lt $conditionals.Length; $cIdx++) {
$conditional = $conditionals[$cidx]
@manofstick
manofstick / driver.ps1
Last active August 5, 2018 01:04
Battle Royale - 2: Finding elements
View driver.ps1
$platforms = @("--platform:x86","--platform:x64")
$containers = @("", "--define:IMMUTABLESORTEDDICTIONARY")
$types = @("", "--define:FASTCOMPARER")
$orders = @("--define:STRIPES", "--define:RANDOM")
For ($cIdx=0; $cIdx -lt $containers.Length; $cIdx++) {
$container = $containers[$cIdx]
For ($pIdx=0; $pIdx -lt $platforms.Length; $pIdx++) {
$platform = $platforms[$pIdx]
For ($tIdx=0; $tIdx -lt $types.Length; $tIdx++) {
@manofstick
manofstick / driver.ps1
Last active August 4, 2018 20:16
Battle Royale - 1: Adding elements
View driver.ps1
$platforms = @("--platform:x86","--platform:x64")
$containers = @("", "--define:IMMUTABLESORTEDDICTIONARY")
$types = @("", "--define:FASTCOMPARER")
$orders = @("--define:STRIPES", "--define:RANDOM")
For ($cIdx=0; $cIdx -lt $containers.Length; $cIdx++) {
$container = $containers[$cIdx]
For ($pIdx=0; $pIdx -lt $platforms.Length; $pIdx++) {
$platform = $platforms[$pIdx]
For ($tIdx=0; $tIdx -lt $types.Length; $tIdx++) {