Skip to content

Instantly share code, notes, and snippets.

@deneuxj
deneuxj / gist:4451408
Created January 4, 2013 10:04
Demonstration of how to extend System.Random using extension methods in F#.
open System
(* Low-level F# implementation *)
let newRandomChar getRandomInt (chars : char[]) =
let idx = getRandomInt()
chars.[idx]
let newRandomWord (getRandomChar : unit -> char) length =
let chars =
Array.init length (fun _ -> getRandomChar())
@deneuxj
deneuxj / gist:1603109
Created January 12, 2012 21:06
Parallel draw/update game component for XNA
namespace CleverRake.XnaUtils
open Microsoft.Xna.Framework
open System.Threading
type IFramePerSecondCounter =
abstract FramesPerSecond : float
/// An update-able and drawable game component which performs light updates on the main thread,
/// then draws on a separate thread in parallel of more computation-heavy updates.
@deneuxj
deneuxj / FilterTextFile.fsx
Created October 24, 2011 16:18 — forked from OnorioCatenacci/FilterTextFile.fsx
A quick and dirty F# Shell Script to filter a text file for all lines which match a certain string
(*
* Filter a specified file into a second file
* Onorio Catenacci
* 21 October 2011
*)
#r "System.dll"
open System.IO
//Remember:
@deneuxj
deneuxj / Score4.fs
Created July 15, 2011 17:41
History of my edits to speed up a Score4 AI originally ttsiodra
// Learn more about F# at http://fsharp.net
open System.Collections.Generic
let width = 7
let height = 6
let maxDepth = 7
let orangeWins = 1000000
let yellowWins = -orangeWins
let debug = ref true