Skip to content

Instantly share code, notes, and snippets.

View robertpi's full-sized avatar

Robert Pickering robertpi

View GitHub Profile
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using ZeroMQ;
namespace Examples
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using ZeroMQ;
namespace Examples
{
// Are you an F# programer with a liberal point of view?
// Do you want to show your happiness at the advancement of gay right?
// But hate the convience of using a facebook app to rainbowify your profile photo?
// Simple, use this script instead!
open System.Drawing
open System.Runtime.InteropServices
open System.Drawing.Imaging
open System.IO
open System.Windows.Forms
open System.Drawing
let dt = 0.01
let sigma=10.
let beta=8./3.
let rho=28.0
let lorentzDeriv x y z dt sigma beta rho =
@robertpi
robertpi / gist:11278941
Created April 25, 2014 05:54
Dns.GetHostAddresses only returns one address in mono
robert@fotnmc:~/code/BitcoinFs$ nslookup seed.bitcoin.sipa.be
Server: 127.0.0.1
Address: 127.0.0.1#53
Non-authoritative answer:
Name: seed.bitcoin.sipa.be
Address: 71.172.136.155
Name: seed.bitcoin.sipa.be
Address: 108.183.38.208
Name: seed.bitcoin.sipa.be
[{"Name":"Feck"},{"Name":"Arse"},{"Name":"Arse"}]
module ParkingMeterKata
open System
// coins accepted by the system
type Coin =
| TenCents = 10
| TwentyCents = 20
| FiftyCents = 50
| OneEuro = 100
| TwoEuro = 200
@robertpi
robertpi / gist:2964793
Created June 21, 2012 09:18
F# record implementing an interface
namespace MyNamespace
type IMyInterface =
abstract GetValue: unit -> string
type MyRecord =
{ MyField1: int
MyField2: string }
interface IMyInterface with
member x.GetValue() = x.MyField2
// 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 December 12, 2010 11:38
A solves sudoku puzzels using Microsoft Solver Foundation and F#.
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]