Skip to content

Instantly share code, notes, and snippets.

Robert Pickering robertpi

Block or report user

Report or block robertpi

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
@robertpi
robertpi / gist:2964793
Created Jun 21, 2012
F# record implementing an interface
View gist:2964793
namespace MyNamespace
type IMyInterface =
abstract GetValue: unit -> string
type MyRecord =
{ MyField1: int
MyField2: string }
interface IMyInterface with
member x.GetValue() = x.MyField2
View rolly.fs
// this roll why function seems to work on a small 5 x 5 matrix
// but doesn't for bigger 227 x 227 image
// no idea why
let rollArrayY yLength shift (data:'t[]) =
let shift =
if shift > 0 then
shift
else
yLength + shift
let out:'t[] = Array.zeroCreate data.Length
View gist:5560670
[{"Name":"Feck"},{"Name":"Arse"},{"Name":"Arse"}]
View ParkingMeterKata.fs
module ParkingMeterKata
open System
// coins accepted by the system
type Coin =
| TenCents = 10
| TwentyCents = 20
| FiftyCents = 50
| OneEuro = 100
| TwoEuro = 200
View unfold.fsx
let walkCommits (hash: Hash, count) =
printfn "%s %s %s" objectsDir hash.DirectoryName hash.FileName
let objectPath = Path.Combine(objectsDir, hash.DirectoryName, hash.FileName)
printfn "objectPath: %s" objectPath
let gitObject = GitObject.ParseFile objectPath
match gitObject with
| Commit (_, commit) ->
match commit.Parent with
| Some (hash) when count < 10 ->
View salary.fsx
// Learn more about F# at http://fsharp.net
let rate = 0.04
let baseSalary = 100000.
let baseYear = 2011
let salaries =
Seq.unfold(fun (year, salary) ->
let nextYear, nextSalary = year + 1, salary * (1.0 + rate)
@robertpi
robertpi / solverFoundationSudoku.fs
Created Dec 12, 2010
A solves sudoku puzzels using Microsoft Solver Foundation and F#.
View solverFoundationSudoku.fs
open Microsoft.SolverFoundation.Services
open Microsoft.SolverFoundation.Common
open System.Collections.Generic
open Microsoft.SolverFoundation.SfsWrapper
// helper functions for grouping elements of the solution
let flatten (matrix:'a[,]) = matrix |> Seq.cast<'a> |> Seq.toArray
let getColumn c (matrix:_[,]) =
flatten matrix.[*,c..c]
You can’t perform that action at this time.