This blog created for F# Advent 2016 (English)
Full source code can be found here
- 2016-12-10
- New performance test - Anthony Lloyd (@AnthonyLloyd) suggested that I compare against Prime.Vmap.
open System | |
open System.Collections.Generic | |
[<Struct>] | |
type Pair<'a when 'a: equality> = | |
val v: 'a | |
val w: 'a | |
new(x,y)= {v=x;w=y} | |
type Tone = | |
| Rest = 0 | |
| GbelowC = 196 | |
| A = 220 | |
| Asharp = 233 | |
| B = 247 | |
| C = 262 | |
| Csharp = 277 | |
| D = 294 | |
| E = 330 |
open System.IO | |
open System.Collections.Concurrent | |
// A Merkle tree for a file system might look like this | |
// PASTE!! | |
let isDirectory(path:string) = | |
let attr = File.GetAttributes(path) | |
attr.HasFlag(FileAttributes.Directory) |
type json = | |
| Number of float | |
| String of string | |
| Boolean of bool | |
| Array of json list | |
| Object of (string * json) list | |
| Null | |
static member (?) (this,name:string) = | |
match this with | |
| Object xs -> xs |> List.find (fst >> (=) name) |> snd |
open System | |
open System.IO | |
open System.Diagnostics | |
let downloadDependencies deps = | |
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__ | |
if not (File.Exists "paket.exe") then | |
async { | |
let url = "http://fsprojects.github.io/Paket/stable" |
namespace CommonStuff | |
open Microsoft.FSharp.Reflection | |
open System | |
open System.Text | |
open System.Collections.Generic | |
open System.Linq | |
open System.Drawing | |
open System.Windows.Forms |
#I __SOURCE_DIRECTORY__ | |
#r "libs/NuGet.Core.dll" | |
#r "System.Xml.Linq" | |
open NuGet | |
open System | |
open System.IO | |
module NuGet = |
// This is am example of an immediate write / random access cursor for Excel with basic formatting options. | |
// Implementation is based on a concrete, non generic writer monad with no payload ("do!"" only) (only state). | |
// Instead of directl writing to excel, an alternatives would be a random acces to a | |
// copy-on-write list (or even a mutable array) and then bulk-write the result to excel in one shot. | |
// When only forward access would have been required, a simple seq expression with yields would have been enough. | |
// Anyway, it is a demonstration on how to "hide" pseudo-mutable state that is passed through a computation. | |
// | |
// I personally use it for generating reports based on various data sources. |
namespace GhFsharpTest | |
open Grasshopper.Kernel | |
open Grasshopper.Kernel.Types | |
type Priority() = | |
inherit GH_AssemblyPriority() | |
override u.PriorityLoad() = | |
GH_LoadingInstruction.Proceed |
This blog created for F# Advent 2016 (English)
Full source code can be found here