This file contains hidden or 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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or 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 BuilderTest () = | |
member this.Yield (evalResult: bool) = | |
evalResult | |
member this.For(source: seq<'a>, body:'a -> seq<'b * bool>) = | |
source | |
|> Seq.collect (fun x -> body x |> Seq.map (fun (idx, expr) -> (x, idx), expr)) | |
member this.For(source: seq<'a>, body:'a -> bool) = | |
source |> Seq.map (fun x -> x, body x) |
This file contains hidden or 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 Food = | |
| Chicken | |
| Rice | |
type Step<'next> = | |
| GetFood of Food * 'next | |
| Eat of Food * 'next | |
| Sleep of hours:int * 'next | |
module Step = |
This file contains hidden or 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 StateId = StateId of int | |
type PlanId = PlanId of int | |
type StepId = StepId of int | |
type State = { | |
LastStateId : StateId | |
LastPlanId : PlanId | |
LastStepId : StepId | |
} | |
type Step = |
This file contains hidden or 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
/// State is a function type that takes a state and | |
/// returns a value and the new state. | |
/// Single case union of the same type. | |
type State<'a, 's> = ('s -> 'a * 's) | |
module State = | |
// Explicit | |
// let result x : State<'a, 's> = fun s -> x, s | |
// Less explicit but works better with other, existing functions: | |
let result x s = |
This file contains hidden or 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 State<'a, 's> = ('s -> 'a * 's) | |
module State = | |
// Explicit | |
// let result x : State<'a, 's> = fun s -> x, s | |
// Less explicit but works better with other, existing functions: | |
let result x s = | |
x, s | |
let bind (f:'a -> State<'b, 's>) (m:State<'a, 's>) : State<'b, 's> = |
This file contains hidden or 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
#r "nuget: FSharp.Data, 4.1.1" | |
open FSharp.Data | |
type TimeData = CsvProvider<"ExampleDates.csv"> | |
let data = TimeData.Load $"{__SOURCE_DIRECTORY__}\\ExampleDates.csv" | |
let analysis = | |
data.Rows | |
|> Seq.map (fun row -> row.ExampleDateTime.Hour) |
This file contains hidden or 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 | |
open System.Collections.Generic | |
module rec SliceMap = | |
[<Struct>] | |
type IndexRange = { | |
Start : int | |
Length : int | |
} |
This file contains hidden or 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 rec TestTypes = | |
type Chicken = { | |
Size : int | |
} with | |
static member ( * ) (c: Chicken, i: int) = | |
{ Size = c.Size * i } | |
static member ( + ) (c1: Chicken, c2: Chicken) = | |
Flock [c1; c2] | |
static member ( + ) (c: Chicken, Flock f) = |
This file contains hidden or 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
// Validating benchmarks: | |
// ***** BenchmarkRunner: Start ***** | |
// ***** Found 3 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\SliceMapPerformanceExploration\bin\Release\net5.0\4e898864-ad69-478b-a9ec-168807204bd8 | |
// command took 1.14s 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\SliceMapPerformanceExploration\bin\Release\net5.0\4e898864-ad69-478b-a9ec-168807204bd8 | |
// command took 1.86s and exited with 0 | |
// ***** Done, took 00:00:03 (3.09 sec) ***** | |
// Found 3 benchmarks: |
OlderNewer