Snippets created by Phillip Trelford

  • LinkedList extensions

    LinkedList functional extension providing find and findi higher order functions that take a predicate function.

    36 people like this
    Posted: 2 years ago by Phillip Trelford

  • Seq.unsort

    Randomizes order of specified sequence

    21 people like this
    Posted: 2 years ago by Phillip Trelford

  • Int32.tryParse

    Converts the string representation of a number in-place to an Int32. A return value of None indicates the conversion failed.

    18 people like this
    Posted: 2 years ago by Phillip Trelford

  • ObservableObject

    The ObservableObject type implements the INotifyPropertyChanged interface used in WPF and Silverlight to notify on changes to properties that are bound to a control. Specify property names type safely using F# Quotations, i.e. <@ this.PropertyName @> when invoking the NotifyPropertyChanged method. If you are following the MVVM pattern then your View Model class can inherit from the ObservableObject type.

    51 people like this
    Posted: 2 years ago by Phillip Trelford

  • Observable.Subject

    The Subject<T> type implements both IObserver<T> and IObservable<T>. It is functionally equivalent to the type of the same name in the Reactive Extensions (Rx) library.

    22 people like this
    Posted: 2 years ago by Phillip Trelford

  • Spreadsheet

    Spreadsheet script runnable inside http://tryfsharp.org includes a custom DataGrid and a parser for simple formulas e.g.: =1+1 =SUM(A1,A2) Add your own functions to the evaluate function. For a more comprehensive implementation check out http://cellz.codeplex.com

    3 people like this
    Posted: 2 years ago by Phillip Trelford

  • Calculator

    Simple Silverlight Calculator UI interactive sample runnable inside http://tryfsharp.org.

    0 people like this
    Posted: 1 years ago by Phillip Trelford

  • Calculator

    Simple Silverlight Calculator UI interactive sample runnable inside http://tryfsharp.org.

    0 people like this
    Posted: 1 years ago by Phillip Trelford

  • Formula Calculator

    Simple formula calculator including dynamic unit of measure support. Run as a script in Try F#, and try formula with units like 3m * 3m.

    0 people like this
    Posted: 1 years ago by Phillip Trelford

  • Miss Grant's Controller Parser

    State machine example, from Martin Fowler's Domain-Specific Languages book, implemented as an External DSL parser in F#. A set of mutually recursive functions are used to parse the string tokens and build the State Machine as an F# record type.

    6 people like this
    Posted: 1 years ago by Phillip Trelford

  • ReplaySubject

    The ReplaySubject<T> type implements both IObserver<T> and IObservable<T>. It is functionally equivalent to the class of the same name in the Reactive Extensions (Rx) library with a replay buffer of a specified size .

    1 people like this
    Posted: 1 years ago by Phillip Trelford

  • Tetris

    Playable Tetris mini-game. Use arrow keys to move left and right and up to rotate, down to drop. Try it out in the browser on TryFSharp.org

    11 people like this
    Posted: 1 years ago by Phillip Trelford

  • Still Mouse Click Event

    Detects a mouse down then up event without a move.

    3 people like this
    Posted: 1 years ago by Phillip Trelford

  • Turtle

    Turtle graphics library implemented as an internal DSL, providing a very similar syntax to Logo, it is runnable inside TryFSharp.org.

    8 people like this
    Posted: 1 years ago by Phillip Trelford

  • Times Table game

    Simple times table console based game.

    3 people like this
    Posted: 1 years ago by Phillip Trelford

  • JSON Parser

    JSON Parser using Regular Expressions & Active Patterns (just for fun).

    5 people like this
    Posted: 1 years ago by Phillip Trelford

  • Simple JS Calculator

    Simple calculator application for adding numbers, compiles to JavaScript via Pit (v0.1) (http://pitfw.posterous.com). Run: http://trelford.com/PitCalculatorApp.htm

    3 people like this
    Posted: 1 years ago by Phillip Trelford

  • Times Table JS game

    Simple times table browser based game., compiles to JavaScript via Pit (v0.1) (http://pitfw.posterous.com). Run: http://trelford.com/SevenSixes.htm

    2 people like this
    Posted: 1 years ago by Phillip Trelford

  • Mini IoC Container

    Minimal Inversion of Control (IoC) Container for Dependency Injection (DI) in under 100 lines of code. Implements the 3 Rs of DI: Register, Resolve, Release. Note: missing thread safety and fluent interface.

    8 people like this
    Posted: 1 years ago by Phillip Trelford

  • Starbucks

    Simple DSL for describing cups of Starbucks coffee and computing prices (in dollars).

    9 people like this
    Posted: 1 years ago by Phillip Trelford

  • Baccarat

    Shuffles a deck of cards, deals 2 hands applying punto banco rules before declaring a winner or a tie.

    4 people like this
    Posted: 1 years ago by Phillip Trelford

  • Point of Sale

    10 line Point of Sale (POS) application takes barcodes from a USB barcode scanner or keyboard adding matching products. Entering an empty string completes the action and gives the total.

    6 people like this
    Posted: 1 years ago by Phillip Trelford

  • PacMan Maze

    PacMan maze view runnable inside TryFSharp.org

    5 people like this
    Posted: 1 years ago by Phillip Trelford

  • Pong

    Pong video game runnable inside TryFSharp.org. Player 1 keys 'Q' - up, 'A' - down. Player 2 keys 'P' - up, 'L' - down.

    6 people like this
    Posted: 1 years ago by Phillip Trelford

  • WrapPanel

    Positions child elements in sequential position from left to right, breaking content to the next line at the edge of the containing box. Tryable at http://tryfsharp.org

    3 people like this
    Posted: 1 years ago by Phillip Trelford

  • Berzerk

    Zombie state machine code sample. Use arrow keys to move humanoid. Robots activate when in range of humanoids. Try it out in the browser with TryFSharp.org.

    6 people like this
    Posted: 12 months ago by Phillip Trelford

  • Minesweeper Kata

    Solution to Minesweeper Kata challenge at Goto Copenhagen 2012 conference "Programming with the Stars" track.

    4 people like this
    Posted: 12 months ago by Phillip Trelford

  • Minesweeper Kata 2

    Solution to Minesweeper Kata second challenge at Goto Copenhagen 2012 conference "Programming with the Stars" track. Runnable at http://tryfsharp.org.

    2 people like this
    Posted: 12 months ago by Phillip Trelford

  • Minesweeper Tweet

    Minesweeper computation Kata as a tweet (140 characters) not counting code to open namespace and to prepare field as a 2D array.

    6 people like this
    Posted: 11 months ago by Phillip Trelford

  • Brainfuck

    A minimal Brainfuck Interpreter (<30 lines) running Hello World!

    6 people like this
    Posted: 11 months ago by Phillip Trelford

  • Befunge

    Minimal Befunge-93 interpreter.

    2 people like this
    Posted: 11 months ago by Phillip Trelford

  • PacMan

    Single level retro game playable inside TryFsharp using the cursor keys.

    6 people like this
    Posted: 10 months ago by Phillip Trelford

  • Game of Life

    Conway's Game of Life example at F#unctional Londoners July 2012 meetup.

    1 people like this
    Posted: 9 months ago by Phillip Trelford

  • Phone number to words

    Creates all possible mobile phone letter combinations from a number.

    2 people like this
    Posted: 7 months ago by Phillip Trelford

  • Hashtable

    Readonly generic Hashtable class implementation example.

    4 people like this
    Posted: 7 months ago by Phillip Trelford

  • Reversi Kata

    Quick & dirty solution to Reversi kata: http://codingdojo.org/cgi-bin/wiki.pl?KataReversi

    1 people like this
    Posted: 6 months ago by Phillip Trelford

  • OData Type Provider to StackOverflow

    References and type definition to open StackOverflow API over OData

    6 people like this
    Posted: 6 months ago by Phillip Trelford

  • Contains Phrase

    Returns a value indicating whether the specified phrase occurs within the given text.

    4 people like this
    Posted: 6 months ago by Phillip Trelford

  • Mocking library

    F# Mocking library with a fluent interface Moq users should find familiar. Generate mocks for interfaces and abstract types. Supports mocking methods, properties and events. Specify arguments as wildcards or values to match. Define results as values, computed values or exceptions.

    5 people like this
    Posted: 6 months ago by Phillip Trelford

  • Reversi Kata solution

    Reversi Kata solution from February 2013 London F# Meetup Coding Kata.

    4 people like this
    Posted: 3 months ago by Phillip Trelford

  • Eval Quotations

    Evaluates a useful subset of F# quotations at run-time (without the F# PowerPack API).

    3 people like this
    Posted: 3 months ago by Phillip Trelford

  • Calculate PI using Monte Carlo

    Estimate the value of PI using a Monte Carlo simulation.

    3 people like this
    Posted: 2 months ago by Phillip Trelford

  • A Happy Ending

    Generates Text art in the style of Philippe Decrauzat's D.T.A.B.T.W.H.A.H.E. 2010 currently exhibited at the MoMA NYC

    1 people like this
    Posted: 15 days ago by Phillip Trelford