Skip to content

Instantly share code, notes, and snippets.

View latkin's full-sized avatar

Lincoln Atkinson latkin

View GitHub Profile
@latkin
latkin / README.md
Last active August 29, 2015 14:12
Extended 'for' loops for F#

Backing code and examples for two different mini-frameworks adding extended imperative-style for loops in F#.

Discussed in blog post here.

@latkin
latkin / readme.md
Last active August 29, 2015 14:12
Blog: Non-transitive dice
@latkin
latkin / test.fsx
Created April 22, 2015 03:38
Try block perf overhead
#time ;;
let testNoTry () =
let mutable x = 0
for i in 1 .. 1000000000 do
x <- x + 1
x
let testTry () =
let mutable x = 0
@latkin
latkin / code.fsx
Last active August 29, 2015 14:20
Benchmark of groupBy perf
open System.Collections.Generic
open System.Diagnostics
let groupBy keyMaker elements =
elements |> Seq.groupBy keyMaker |> Seq.length
let loopGroup keyMaker elements =
let d = Dictionary<string, seq<'a>>()
for p in elements do
let key = keyMaker p
@latkin
latkin / ops.fsx
Created April 30, 2015 01:45
Scoping nonstructural operators
[<AutoOpen>]
module Ops =
open NonStructuralComparison
let inline nsHash x = hash x
let inline nsCompare x = compare x
let inline (=&) a b = a = b
let inline (<>&) a b = a <> b
let inline (<&) a b = a < b
let inline (>&) a b = a > b
let inline (<=&) a b = a <= b
@latkin
latkin / code.fsx
Last active August 29, 2015 14:20
Seq.cache repro
open System.Collections.Generic
let someDataSource = seq{ 1 .. 100 }
let ordersForTask = Dictionary<int, seq<int>>()
let getOrdersForTask task =
match ordersForTask.TryGetValue task with
| true, orders -> orders
| false, _ ->
let orders =
@latkin
latkin / readme.md
Last active August 29, 2015 14:21
Blog: A handy Powershell filter for converting plain text to objects
@latkin
latkin / readme.md
Last active August 29, 2015 14:21
Blog: Null-checking considerations in F#
@latkin
latkin / fsharp4all.png
Last active August 29, 2015 14:25
F# 4.0 contributor photo
fsharp4all.png
@latkin
latkin / ProvidedTypes.fs
Last active October 6, 2015 13:02
Static params to provided methods
(*
* all of ProvidedTypes.fs
* as of https://github.com/fsprojects/FSharp.TypeProviders.StarterPack/blob/245fe3b0126ac6a326a14a0f6b1ef569680b08b3/src/ProvidedTypes.fs
*)
// then add to the bottom
interface ITypeProvider2 with
member __.GetStaticParametersForMethod(methodWithoutArguments:MethodBase) =
match methodWithoutArguments.Name with