Skip to content

Instantly share code, notes, and snippets.

Dave Thomas 7sharp9

Block or report user

Report or block 7sharp9

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
7sharp9 / ActivePatterns.fs
Created Nov 20, 2018
Language Essentials Active Patterns
View ActivePatterns.fs
namespace ClassLibrary1
open System
module SingleCase =
let (|UpperCase|) (x:string) = x.ToUpper()
//PM usage
match "foo" with
7sharp9 / tech001.fs
Created Nov 2, 2018
Introduction to quotations
View tech001.fs
open System
open Microsoft.FSharp.Quotations
open Microsoft.FSharp.Quotations.Patterns
open Microsoft.FSharp.Quotations.ExprShape
open Microsoft.FSharp.Quotations.DerivedPatterns
let qliteral =
let addAndMultiply a b =
7sharp9 / parser.fs
Last active Nov 19, 2015
toml fparsec
View parser.fs
open System
open System.Globalization
open FParsec
type Token =
| KeyGroup of string list
| KeyValue of string * obj
let (<||>) p1 p2 = attempt (p1 |>> box) <|> attempt (p2 |>> box)
let spc = many (anyOf [' '; '\t'])
View FSHelloSceneKitViewController.fs
namespace FSHelloSceneKit
open System
open MonoTouch.UIKit
open MonoTouch.Foundation
open MonoTouch.SceneKit
type FSHelloSceneKitViewController () =
inherit UIViewController()
View EasyLayout.fs
module EasyLayout
open System
open System.Drawing
open Microsoft.FSharp.Quotations
open Microsoft.FSharp.Quotations.Patterns
open Microsoft.FSharp.Quotations.DerivedPatterns
open MonoTouch.Foundation
open MonoTouch.UIKit
7sharp9 / gist:8421623
Created Jan 14, 2014
average of 10 runs of an fsharp script
View gist:8421623
for i in {1..10}; do time fsharp hello world.fsx; done 2>&1 | grep ^real | sed -e s/.*m// | awk '{sum += $1} END {print sum / NR}'
7sharp9 / tokenizer.fs
Last active Jan 2, 2016
tokenizer snippets
View tokenizer.fs
let idents tokens =
//reverse the tokens
let tokens = tokens |> Array.rev |> List.ofArray
let rec loop tokens result =
match tokens with
| [] -> result
| (name, token: TokenInformation) :: tail ->
match token.TokenName with
| "IDENT" -> loop tail (name :: result)
| "DOT" -> loop tail result
7sharp9 / arrays.fs
Created Oct 13, 2013
Array declarations:
View arrays.fs
let things = [|"One";"Two";"Three"|]
let things2 = [|"One"
let things3 = [|
7sharp9 / BasicExample.fs
Last active Dec 22, 2015
An Blank screen Xna App
View BasicExample.fs
namespace BasicExample
open Microsoft.Xna.Framework
type Basic() as x =
inherit Game()
let graphics = new GraphicsDeviceManager(x)
override x.Draw (gameTime) = x.GraphicsDevice.Clear(Color.CornflowerBlue)
7sharp9 / file.cs
Last active Dec 17, 2015
Example of record construction syntax for multiple constructors
View file.cs
public class HtmlProjectFileType : KnownProjectFileType
public new const string Name = "HTML";
public const string HTML_EXTENSION = ".html";
public const string HTM_EXTENSION = ".htm";
public new static readonly HtmlProjectFileType Instance;
private HtmlProjectFileType() : base(Name, "Html", new[] {HTML_EXTENSION, HTM_EXTENSION}) { }
You can’t perform that action at this time.