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 TrelfordSeq.unsort
Randomizes order of specified sequence
21 people like this
Posted: 2 years ago by Phillip TrelfordInt32.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 TrelfordObservableObject
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 TrelfordObservable.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 TrelfordSpreadsheet
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 TrelfordCalculator
Simple Silverlight Calculator UI interactive sample runnable inside http://tryfsharp.org.
0 people like this
Posted: 1 years ago by Phillip TrelfordCalculator
Simple Silverlight Calculator UI interactive sample runnable inside http://tryfsharp.org.
0 people like this
Posted: 1 years ago by Phillip TrelfordFormula 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 TrelfordMiss 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 TrelfordReplaySubject
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 TrelfordTetris
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 TrelfordStill Mouse Click Event
Detects a mouse down then up event without a move.
3 people like this
Posted: 1 years ago by Phillip TrelfordTurtle
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 TrelfordTimes Table game
Simple times table console based game.
3 people like this
Posted: 1 years ago by Phillip TrelfordJSON Parser
JSON Parser using Regular Expressions & Active Patterns (just for fun).
5 people like this
Posted: 1 years ago by Phillip TrelfordSimple 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 TrelfordTimes 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 TrelfordMini 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 TrelfordStarbucks
Simple DSL for describing cups of Starbucks coffee and computing prices (in dollars).
9 people like this
Posted: 1 years ago by Phillip TrelfordBaccarat
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 TrelfordPoint 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 TrelfordPong
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 TrelfordWrapPanel
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 TrelfordBerzerk
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 TrelfordMinesweeper 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 TrelfordMinesweeper 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 TrelfordMinesweeper 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 TrelfordBrainfuck
A minimal Brainfuck Interpreter (<30 lines) running Hello World!
6 people like this
Posted: 11 months ago by Phillip TrelfordBefunge
Minimal Befunge-93 interpreter.
2 people like this
Posted: 11 months ago by Phillip TrelfordPacMan
Single level retro game playable inside TryFsharp using the cursor keys.
6 people like this
Posted: 10 months ago by Phillip TrelfordGame 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 TrelfordPhone number to words
Creates all possible mobile phone letter combinations from a number.
2 people like this
Posted: 7 months ago by Phillip TrelfordHashtable
Readonly generic Hashtable class implementation example.
4 people like this
Posted: 7 months ago by Phillip TrelfordReversi 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 TrelfordOData Type Provider to StackOverflow
References and type definition to open StackOverflow API over OData
6 people like this
Posted: 6 months ago by Phillip TrelfordContains Phrase
Returns a value indicating whether the specified phrase occurs within the given text.
4 people like this
Posted: 6 months ago by Phillip TrelfordMocking 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 TrelfordReversi Kata solution
Reversi Kata solution from February 2013 London F# Meetup Coding Kata.
4 people like this
Posted: 3 months ago by Phillip TrelfordEval 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 TrelfordCalculate PI using Monte Carlo
Estimate the value of PI using a Monte Carlo simulation.
3 people like this
Posted: 2 months ago by Phillip TrelfordA 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