Backing code and examples for two different mini-frameworks adding extended imperative-style for
loops in F#.
Discussed in blog post here.
Backing code and examples for two different mini-frameworks adding extended imperative-style for
loops in F#.
Discussed in blog post here.
Sample code from blog post Non-transitive Grime Dice, via Mathematica.
#time ;; | |
let testNoTry () = | |
let mutable x = 0 | |
for i in 1 .. 1000000000 do | |
x <- x + 1 | |
x | |
let testTry () = | |
let mutable x = 0 |
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 |
[<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 |
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 = |
Sample code for blog post A handy Powershell filter for converting plain text to objects
Sample code for blog post Null-checking considerations in F# - it's harder than you think
(* | |
* 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 |