-
How to Leverage Pattern Matching (16th April 2007)
"Compared to conventional programming languages, F# takes dynamic dispatch to a whole new level using an approach called pattern matching. This article guides the reader through the fundamental concepts that underpin pattern matching before providing some examples demonstrating the power of pattern matching in general programming..."
-
The Essence of Functional Programming (30th April 2007)
"F# is fundamentally a functional programming language and the use of functions instead of objects often leads to shorter and clearer code. Indeed, many of the benefits of functional programming are already known to OO programmers in the form of design patterns..."
-
F# Development in Visual Studio 2005 (14th May 2007)
"The F# distribution includes extensions to Microsoft Visual Studio that provide a rich development environment for F# programmers. In this article, we shall describe how this development environment can be setup and used to make development as easy and productive as possible..."
This article contains a 5 minute tutorial video demonstrating F# development inside Visual Studio 2005.
-
Objects and Augmentations in F# (31st May 2007)
"In addition to functional programming, the F# language also offers object-oriented programming (OOP) in harmony with the .NET platform. The F# language takes powerful OOP concepts from C# and supplements them with elegant functional constructs. The result combines the best aspects of functional and object-oriented programming..."
-
Using the built-in Data Structures (15th June 2007)
"The .NET framework provides a wide variety of mutable data structures and the F# standard library supplements these with several immutable data structures that provide elegant functional interfaces. This article describes many of the built-in data structures, how they are used and when they are most applicable..."
-
Designing and implementing a Sudoku Solver (30th June 2007)
"This article walks through the design and implementation of a complete GUI application for solving Sudoku puzzles. This is perhaps the smallest interesting GUI application that demonstrates many different advantages of the F# programming language, including functional programming and .NET interoperability..."
Download and play the demo (requires .NET 2.0 or later)
-
Introduction to Threading (15th July 2007)
"The .NET platform provides parallel execution of code through multithreading. A thread is an independent execution path, able to run simultaneously with other threads. This article describes the fundamentals of .NET threading and how this functionality can be leveraged elegantly by F# programs..."
-
Introduction to DirectX (31st July 2007)
"The .NET platform contains library interfaces to almost all of the functionality bundled with the Windows platform. Hardware-accelerated graphics are no exception and Managed DirectX (MDX) for .NET provides a high-level and type-safe interface to the DirectX API..."
-
Exploiting Tail Recursion (16th August 2007)
"Recursion is essential to functional programming and practical use of functional programming languages and a functional style requires the ability to write recursive functions that do not consume stack space. Function calls that require no stack space are called tail calls. This article describes the use of tail calls to write robust and efficient tail recursive functions in F#..."
-
Combinator Heaven (1st September 2007)
"The ability to write higher-order functions that compose other functions in interesting ways is one of the most powerful forms of abstraction provided by the functional programming paradigm. Such functions are known as combinators . This article describes the basic concepts behind combinators with a variety of examples to demonstrate how practically useful this form of functional abstraction can be..."
-
A simple FFT implementation (18th September 2007)
"Writing an implementation of the Fourier transform is an excellent lesson in algorithm design and optimization. Moreover, the Fourier transform is one of the most essential tools in numerical computing, with applications ranging from spectral analysis to the multiplication of large integers. This article describes the design and implementation of a simple but efficient FFT..."
-
Parsing text with Lex and Yacc (30th September 2007)
"The tool stack bundled with the F# distribution includes fslex and fsyacc tools that help in the construction of parsers. The ability to parse data in different formats is often very useful, particularly when translating between representations. This article introduces the concepts of lex and yacc-based parsing and describes how these tools may be used to construct robust and efficient parsers quickly and easily..."
-
Balanced binary search trees (16th October 2007)
"Functional programming languages like F# excel at handling immutable data structures. In the interests of efficiency, such data structures are typically based upon trees rather than hash tables. Key benefits include the ability to express algorithms elegantly using a declarative style and the inherent thread safety of immutable data structures makes them ideal for concurrent programming. This article describes the design and implementation of a basic balanced binary search tree data structure similar to that of the built-in Set module..."
-
Optimizing a simple bytecode interpreter (31st October 2007)
"Interpreter and compiler writing is the bread and butter of the ML family of languages and F# is no exception. This article describes the design, implementation and optimization of an interpreter for a simple bytecode language..."
-
Sequence expressions and comprehensions (16th November 2007)
"The .NET framework provides a powerful generic interface called IEnumerable that allows containers to be treated as arbitrary sequences. The approach is now widely used in C# but F# takes IEnumerable to a new level with its Seq data structure. This article describes abstract sequences in F#, the comprehension syntaxes provided by F# to make their construction simpler and clearer and practical applications of sequences with several examples..."
-
Parser combinators (30th November 2007)
"Certain applications are extremely well suited to functional programming and parsing is one of them. Specifically, the ability to write functional combinators that allow parsers for everything from integers up to symbolic expressions to be composed is more general and provides more opportunity for code reuse than the use of conventional parser generators such as fslex and fsyacc. This article explains how parser combinators may be designed and implemented in F#, using the standard example of a calculator..."
-
Quick introduction to web services and databases (20th December 2007)
"The F# programming language combines the expressive power of a modern functional programming language with the comprehensive libraries provided by the .NET framework. This article provides a quick introduction to two of the most widely used aspects of the .NET framework: web services and databases..."
-
Language-oriented programming: The Term-level Interpreter (31st December 2007)
"Modern software is using a wider variety of languages than ever before. The ability to parse and interpret these languages is of growing importance. Fortunately, F# inherits incredibly powerful constructs for parsing and interpreting other languages from its predecessors. This article explains how the power of F# can be harnessed to write a complete term-level interpreter for a programming language in only a tiny amount of F# code..."
-
Implementing a simple Ray Tracer (16th January 2008)
"Ray tracing is a simple but powerful approach to photorealistic rendering and implementing a ray tracer is an excellent way to learn a programming language and, in particular, to learn about graphics and optimization in the context of numerical algorithms. This article walks through the design and implementation of a basic ray tracer that ray traces a scene in a Windows Forms application that provides the user with rendering options via a menu and real-time incremental update..."
Download and play with the demo (requires .NET 3.5 or later)
-
Factoring numerical methods using combinators (31st January 2008)
"The benefits of functional programming in certain areas like parsers and compilers are well known but functional programming can also be extremely beneficial in many other areas including numerical computation and technical computing. This articles shows how common functional constructs can be used to implement some numerical methods and even complete working programs much more quickly and easily. The clarity of the resulting implementations is remarkable thanks, in particular, to the use of combinators..."
-
Graph plotting with Windows Presentation Foundation (16th February 2008)
"The advent of the .NET Framework 3.0 brings an exciting new technology to the Windows platform for the first time: hardware-accelerated vector graphics as part of Windows Presentation Foundation. This part of Microsoft's standard library allows programmers to define resolution-independent vector graphics in the form of arbitrary paths and shapes and visualize them in an interactive GUI. This article describes how these features can be used in F# programs and builds a simple graph plotter as an example..."
-
Embedding XNA in Windows Forms (29th February 2008)
"Microsoft's XNA library is conventionally used for whole-screen games programming but related GUI applications such as level editors can often benefit from the ability to reuse the same XNA-based rendering code in a Windows Forms application. This article describes how an XNA-based Windows Forms control can be written in F#, allowing XNA to be used in an ordinary Windows application..."
-
Numerical Libraries: special functions, interpolation and random numbers (16th March 2008)
"The F# programming language provides an excellent foundation for technical computing on the Windows platform thanks to its high-performance interactive sessions and integrated support for mathematical types. This article is our first look at numerical libraries, both free and commercial, and describes the implementation quality and easy of use of these libraries in the context of special functions, interpolation and random numbers..."
-
Reducing development costs with Static Typing (31st March 2008)
"The F# language arms programmers with the most sophisticated static type system of any mainstream programming language. This static type system can be used to remove large classes of common bugs that are otherwise tedious or impossible to track down, drastically reducing software development costs. However, learning how and when to leverage such a type system is an art that requires significant effort to learn. This article describes idiomatic F# style and a variety of techniques that can be used to leverage the static type system in order to catch errors earlier and more easily..."
-
Numerical Libraries: linear algebra and spectral methods (16th April 2008)
"This article revisits the subject of numerical libraries for .NET, this time in the context of linear algebra and spectral methods. Specifically, the use and performance of various free and commercial numerical libraries are examined for the computation of eigenvalues and Fourier transforms. This includes a complete 1D FFT interface for F# to the excellent FFTW library..."
-
Surviving in the multicore era with Microsoft's ParallelFX (30th April 2008)
"As the world transitions to multicore desktop computers over the next few years it is essential that software evolves to take advantage of this new dimension in processing power by exposing parallelism. Any software products that fail to evolve will suffer catastrophic losses in sales. The F# programming language uniquely combines natural parallelism at the language level with state-of-the-art capability at the implementation level thanks to its .NET foundation. Microsoft's new Task Parallel Library (TPL) is the keystone in building parallel F# programs and this article explains how this is done using Microsoft's latest Community Technology Preview (CTP) of the TPL..."
-
Porting and optimizing the SciMark2 benchmark (15th May 2008)
"The SciMark2 benchmark is a suite of numerical algorithms that were originally collated into a benchmark for scientific computing on the Java platform. Porting this benchmark to F# provides an excellent tutorial on the implementation of efficient numerical algorithms and the existing C# implementation of this benchmark can be used for comparison. The results illustrate the strengths and weaknesses of the current F# implementation in terms of performance..."
-
Scalable distributed parallelism with MPI.NET (31st May 2008)
"High-performance programs are often run on clusters of machines and the Message Passing Interface (MPI) is the defacto standard for inter-process communication for this kind of distributed parallelism. This article demonstrates just how easily existing .NET libraries can be used to parallelize F# programs across clusters of machines using MPI..."
-
Real-time Finite Element Materials simulation (15th June 2008)
"Finite Element Materials simulations (FEMs) model a continuous volume of material by breaking it down into a discrete representation with many finite parts. This article describes a simple but fun program that simulates the dynamics of a 2D system of particles and springs in real-time. The program includes an interactive GUI visualization based upon Windows Presentation Foundation..."
Download and play the demo (requires .NET 3.0 or later)
-
Interoperating with native code from F# (30th June 2008)
"Although the F# programming language offers many improvements over older languages such as unmanaged C, C++ and Fortran the need to interoperate with native code can still arise. The two most important uses for native code interoperability are performance and legacy. This article describes how native code can be invoked from F# programs, including essential design advice for building robust interfaces in this otherwise error-prone task..."
-
Mathematica interoperability (16th July 2008)
"The Mathematica integrated technical computing environment from Wolfram Research is an incredibly powerful cross platform development environment, language and enormous standard library specifically designed for technical computing. Mathematica's .NET-Link technology is designed to allow Mathematica programs to interoperate with .NET languages such as C#. This article examines the hugely productive marriage of the F# programming language with Mathematica and demonstrates how Mathematica can be controlled entirely from F# programs, allowing Mathematica's awesome functionality to be tapped from a much higher performance and more scalable language..."
-
Implementing XML-RPC clients and servers (31st July 2008)
"XML-RPC is a protocol for remote procedure calls that is built upon the XML format. Method calls are packaged up by the client as an XML request sent via HTTP to the server whereupon action is taken and a response is packaged up and returned in the same way. This article demonstrates how elegantly F# programs can handle XML data using combinators and describes how a complete client-server pair using XML-RPC can be designed and built from scratch using only a small amount of library code and the .NET framework..."
-
Language oriented programming: Term Rewriting (16th August 2008)
"An interesting and powerful alternative to the conventional term-level interpreter is called term rewriting. Rather than reducing expressions down to values, term rewriting simply evaluates expressions by performing substitutions and the result of each substitution is another expression. This approach is particularly well suited to computer algebra systems such as Mathematica but is also an underappreciated alternative to dynamically-typed programming languages that can integrate useful features like pattern matching and make techniques like partial specialization far easier. This article describes how a simple term rewriter can be constructed in the F# programming language..."
-
Run-time code generation using System.Reflection.Emit (31st August 2008)
"The .NET platform represents a radical departure from the previous generation of native-code compiled languages. Whereas languages such as C++ and Fortran have distinct compilation and execution phases, the .NET platform deliberately blurs this distinction with run-time compilation of a distributable platform-independent Common Intermediate Language (CIL). This article examines the use of run-time code generation from F# using the System.Reflection.Emit namespace to implement a compiler for a simple bytecode language..."
-
Named and Optional arguments (16th September 2008)
"The F# programming language provides a variety of useful features that are not found in many other functional programming languages. This is why F# is widely accepted as a functional language for practical use. Named and optional arguments are two related features that can be used to great effect in simplifying interfaces. This article introduces the syntax required to define and use both named and optional arguments in F# and describes some pedagogical uses of these features, with references to existing libraries, as well as examining some of the problems often encountered by programmers using these features..."
-
Concurrent web crawling using asynchronous workflows (30th September 2008)
"Web-enabled technology is now ubiquitous and of huge commercial value. These kinds of programs share two common characteristics: they send information over the internet and they perform tasks concurrently. This article is the first in a series to examine the use of the F# programming language in the growing area of concurrent web programming and, in particular, covers the currently-experimental support for asynchronous workflows..."
-
Triangulated Irregular Networks (TINs) (16th October 2008)
"Adaptive subdivision is a hot topic in computer graphics and forms the foundation of many state-of-the-art algorithms for large scale visualization used for everything from scientific visualization of huge data sets to game graphics that immerse players in expansive virtual worlds. This article describes one of the most popular approaches for the adaptive subdivision of 3D meshes and implements a capable plotting algorithm with real-time visualization using Windows Presentation Foundation showcasing how this simple algorithm works and can be used to solve many different problems..."
-
Low-level optimization tips and tricks: part 1 (31st October 2008)
"The F# programming language is a fantastic tool for technical computing because it combines easy interactive high-level programming with excellent performance and multicore capability. This makes it feasible to solve a wide variety of problems without having to drop to low-level languages like C for performance. This article describes some of the low-level optimizations that underpin the ability to write performant F# programs by leveraging knowledge about the F# compiler as well as the few situations where F# is currently unable to provide competitive performance..."
-
Windows Presentation Foundation: basic controls (16th November 2008)
"Microsoft's new Windows Presentation Foundation (WPF) is the next generation of graphical user interface technology, facilitating rich interactive content that is seamlessly integrated with related technologies. This article is the first in a series examining how WPF can be used from the F# programming language. We begin with an overview of WPF and describe the kinds of GUI applications that will benefit the most from using F# before surveying the basic GUI elements provided by WPF..."
-
Beginner's XNA tutorial (30th November 2008)
"Microsoft's XNA framework is a .NET library intended primarily for games programming that superceded Managed Direct X (MDX). XNA provides a safer, higher-level design that still exposes low-level graphics capabilities in order to provide the best possible performance for graphics-intensive software from a managed language. This article describes everything required to get rendering using the XNA framework with F#, from the most primitive built in effects to custom shader programs..."
-
Reflection and run-time types (16th December 2008)
"The common language run-time (CLR) provides functionality known as reflection that allows programs to create instances of types dynamically, bind types to existing objects and lookup the type of a given object. The F# programming language maps conventional ML type system constructs (tuples, records and variants) onto .NET classes and augments the reflection capabilities of .NET with functions to interrogate F# types. This article describes the reflection capabilities of F# and provides several example applications demonstrating the use of reflection in F# programs..."
-
Solving the Traveling Salesman problem using Simulated Annealing (31st December 2008)
"Finding global minima of an arbitrary function is a significantly more challenging problem than local function minimization and has many practical applications from the simulation of molecules to the design of printed circuit board layouts. Several different global function minimization algorithms exist, many of which make repeated use of local function-minimization algorithms. This article describes a simple and elegant solution to the traveling salesman problem that uses the simulated annealing approach to global function minimization. The results are visualized in real time using Windows Presentation Foundation..."
Download and play the demo (requires .NET 3.5 or later)
-
Simulating smoke in real-time using fluid dynamics (16th January 2009)
"In scientific computing, the task of simulating fluid flow accurately by solving the Navier-Stokes equation is notoriously difficult. However, it is possible to compute numerical approximations quickly enough that fluids dynamics may be simulated in real time. This article describes a simple fluid dynamics simulator that uses Microsoft's Task Parallel Library (TPL) to parallelize the computationally intensive operations and uses Windows Presentation Foundation to visualize the results in real time..."
Download and play the demo (requires .NET 3.5 or later)
-
Emergent behaviour: flocking boids (31st January 2009)
"Artificial life became a popular topic in the 1980s. In particular, with the discovery that simple rules defining the behaviour of individuals could give rise to sophisticated behaviour of groups of individuals. This unexpected result was described as "emergent behaviour" and one of the most famous examples was a computer program called "Boids" that used only three simple rules to govern the dynamics of individuals but produced remarkably realistic flocking behaviour of the population as a whole. This article describes an interactive boids simulator with a graphical user interface implemented using Windows Presentation Foundation..."
Download and play the demo (requires .NET 3.5 or later)
-
Low-level optimization tips and tricks: part 2 (15th February 2009)
"The F# programming language is a fantastic tool for technical computing because it combines easy interactive high-level programming with excellent performance and multicore capability. This makes it feasible to solve a wide variety of problems without having to drop to low-level languages like C for performance. This article describes garbage collection friendliness, data structure specialization, efficient loops and the use of structs to avoid boxing..."
-
Working with Regular Expressions (28th February 2009)
"Regular expressions are a domain-specific language for pattern matching over sequences of characters. This functionality provides a concise and efficient way to dissect strings and, consequently, is used in many forms of string processing including the definition of lexers. This article describes how .NET's support for regular expressions can be used to manpulate strings easily and efficiently from the F# programming language..."
-
Units of Measure (15th March 2009)
"The F# programming language is the first mainstream language in the world to offer statically type checked units of measure. This advanced feature is easy to use and checks the dimensional consistency of programs that manipulate physical quantities. This article introduces units of measure in the F# programming language with the basic constructs, the built-in measures provided with F#, several worked examples of units of measure in action and, finally, a discussion of the caveats of this exciting new language feature..."
-
Aperiodic Tilings (31st March 2009)
"Many sets of polygons can be used to tile an infinite 2D plane. The term "aperiodic tilings" is used informally to refer to tilings that are not periodic. Such tilings are not only of mathematical and scientific interest because they give rise to unexpected diffraction patterns when they appear in quasicrystalline materials but also because they are often beautiful and, consequently, have been used in ornamental decorations for centuries. This article describes a simple program that visualizes tilings using Windows Presentation Foundation where the tilings are described using generic rewrite rules implemented in terms of a .NET interface..."
Download and play the demo (requires .NET 3.5 or later). Right click to choose another tiling.
-
Lempel-Ziv-Welch data compression (15th April 2009)
"LZW is a simple and effective dictionary-based data compression algorithm originally published in 1984 and subsequently used in several prominent places including the GIF image format. This article describes simple purely functional implementations of the compression and corresponding decompression algorithms before examining the translation and optimization of these algorithms into longer but more efficient imperative equivalents. In particular, F#'s sequence expressions are used extensively to create on-the-fly compressors and decompressors ideal for stream processing..."
-
Purely functional data structures: streams and batched queues (30th April 2009)
"This article is the first in a series describing the design and implementation of some very useful purely functional data structures. Lazy evaluation, lazy streams and batched queues are described in detail. In particular, new .NET interfaces, classes and objects are used factor the implementations of the data structure and various built-in interfaces are implemented in order to support equality, comparison and hashing of these new data structures..."
-
Purely functional data structures: real-time queues and catenable lists (15th May 2009)
"This is the second article in a series describing the design and implementation of some purely functional data structures. Real-time queues and catenable lists that provide reliable O(1) time complexity operations are described in detail. In particular, laziness is used to ensure that operations are performed efficiently even when the data structures are used persistently. This culminates in the creation of some useful new data structure implementations..."
-
Visualizing linear algebra: Singular Value Decomposition (31st May 2009)
"Singular Value Decomposition (SVD) is an important algorithm from linear algebra that decomposes a matrix into the product of three simpler matrices. The resulting decomposition has several applications. This article describes the design and implementation of an F# program that computes the SVD of an image and uses it to create a lossy compression algorithm with controllable quality. This involves numerical methods for computing the eigenvalues of real symmetric matrices and interactive visualization of the result as a standalone Windows Presentation Foundation application..."
Download and play the demo (requires .NET 3.0 or later)
-
Least squares: a case study in optimization (16th June 2009)
"The challenge of finding the least squares best fit of a linear sum of functions is a common problem in regression. Linear algebra provides a powerful and general solution by expressing this problem in terms of matrices and then computing the QR decomposition in order to solve the matrix equation. This article describes a remarkably simple implementation of QR decomposition in F# before developing progressively more optimized implementations using the guidance of performance profiles and without sacrificing generality. In particular, heavy use of the F# keyword "inline" is made in order to express efficient reusable numerical methods..."
-
F# development with Visual Studio 2008 (30th June 2009)
"The May 2009 Community Technology Preview (CTP) release of F# includes an advanced Visual Studio mode for F# development. This article describes how this may be installed (including the free version of Visual Studio) and used to evaluate F# code interactively and develop F# applications including the generation of standalone .NET executables suitable for redistribution and the static linking of other .NET assemblies (e.g. C# compiled to DLL) as well as new features in the development environment itself..."
-
2D Scalable Vector Graphics with XNA: part 1 (15th July 2009)
"Vector graphics represent images in terms of lines and curves on a fictional canvas. This resolution-independent representation is ideal for high resolution output devices such as printers but the inevitable march of technology has ossified vector graphics on the desktop as a fundamental component of both Apple's and Microsoft's latest graphical user interfaces. Vector graphics are best represented as trees and manipulated using recursion. Consequently, F# is an extremely powerful tool for writing programs that manipulate vector graphics. This article describes the design and implementation of a simple library for 2D vector graphics written in F# and using XNA for visualization. This would be ideal for games that include 2D graphics with lots of zooming..."
-
Optimizing the Burrows-Wheeler Transform (31st July 2009)
"The Burrows-Wheeler Transform (BWT) is one of the few preconditioners used in data compression and, in particular, is the core of the popular bzip2 compression utility. This article describes a simple 12-line implementation of the BWT in F# and progressively optimizes the implementation to use a customized quicksort then shared-memory parallelism. On 8 cores, the final optimized implementation is over 1,000× faster than the original..."
-
Dynamic programming: Levenshtein edit distance (15th August 2009)
"Levenshtein distance is a metric used to measure the amount of difference between a pair of sequences in terms of the number of insertions, deletions and substitutions required to get from one sequence to the other. Computing the Levenshtein distance is an interesting problem in dynamic programming with many practical applications including spell checkers and the study of DNA in bioinformatics. This article describes how the basic algorithm may be implemented and then optimized, including the use of both generic and specialized memoization..."
-
Traversing networks: the nth-nearest neighbor (31st August 2009)
"Graph theory has a great many practical applications ranging from compiler internals to the study of the structural characteristics of materials. This article describes the design and implementation of a program that finds the nth-nearest neighbors of a given vertex in an infinite graph. This problem is of interest in the context of atomic structures..."
-
Huffman data compression (15th September 2009)
"Data compression algorithms are not only very useful in practice but are also extremely compelling pragmatic examples of programming theory. The popular Huffman data compression algorithm is from the family of entropy encoding compression algorithms. This article walks through the construction of a simple array-based Huffman compression and decompressor written entirely in F# before converting the functions to handle sequences on-demand in order to provide incremental compression and decompression..."
-
Visualizing the Fourier Transform (30th September 2009)
"The Fourier transform is one of the most important numerical methods and underpins most forms of spectral analysis. This article describes a simple image compression technique that uses the Fast Fourier Transform (FFT) to remove the high-frequency components of an image. The 2D FFT is efficiently parallelized and the resulting application provides a WPF GUI allowing the user to control the accuracy of the approximation..."
Download and play the demo (requires .NET 3.0 or later)
-
Low-lock algorithms (15th October 2009)
"Locks are the defacto-standard approach to concurrent programming. With locks, shared mutable resources are protected using mutual exclusion to ensure consistency of the shared state from the point of view of different threads. However, locks are slow and, consequently, many situations can benefit from the avoidance of locks in favor of lower-level solutions. Much research has gone into non-blocking (obstruction-free, lock-free and wait-free) algorithms. This article introduces the concepts that underpin the implementation of non-blocking algorithms, including the .NET memory model, and explains how this can be leveraged to avoid locks with the simple example of lazy evaluation..."
-
Parallelizing the SciMark2 benchmark: part 1 (31st October 2009)
"The SciMark2 benchmark is one of the better benchmarks for programming languages and their implementations in the context of technical computing. This article is the first in a series revisiting the SciMark2 benchmark to examine the potential for parallelizing each of its components. Specifically, the Fast Fourier Transform (FFT) and Successive Over-Relaxation (SOR) tasks are covered in this article. The results are of general interest in the context of improving performance on multicores using parallel programming..."
-
Logic programming: n-queens and knight's tour problems (15th November 2009)
"Logic programming is a paradigm often seen in problem solving and AI. This article introduces the subject of logic programming and explains why the F# language is ideally suited to these kinds of applications, using the familiar examples of solving the n-queens problem and finding a knights tour. Moreover, the differences between the .NET implementation and those bred specifically for this style of programming is described and techniques that can be used to close the performance gap are discussed..."
-
Parsing and visualizing binary Geographic Information System data (30th November 2009)
"Detailed vector descriptions of worldwide geographical data are freely available in the Shapefile format. This article describes how polygonal data can be parsed from the binary Shapefile format and visualized using Windows Presentation Foundation easily and efficiently using F#. The result is a simple program that can be used as the basis for a wide variety of Geographic Information System (GIS) applications from cartography to climatology..."
-
Generating and visualizing 2D mazes (15th December 2009)
"Maze generation is a remarkably complex and diverse subject that essentially falls into the category of network or graph theory but is most often seen in the context of games and puzzles. The characteristics that make a maze interesting for humans to try to navigate are subjective and not easily defined and, consequently, the design and implementation of an automatic maze generator is as much an art as it is a science. This article describes the design and implementation of a simple but effective maze generation algorithm including OpenGL-based visualization. The algorithm is elegantly expressed in terms of recursive functions and purely functional data structures..."
-
Games programming: tic-tac-toe (31st December 2009)
"The game tic-tac-toe, known as Noughts and Crosses in the UK, is one of the simplest popular board games. This article describes an F# program that uses artificial intelligence to provide an infallible computer player, Windows Presentation Foundation to provide a graphical user interface for the desktop and threading to maintain a fluid user experience as the computer thinks about its next move..."
Download and play the demo (requires .NET 3.5 or later).
-
Rigid body dynamics (15th January 2010)
"A common technique to simulate the dynamics of objects is to model them as interacting rigid components. This article describes the design and implementation of a simple F# program that uses rigid body dynamics to simulate balls bouncing around in 2D, using Windows Presentation Foundation for 2D visualization. Dynamics are computed on a worker thread while the GUI thread fetches and visualizes snapshots of the scene..."
Download and play the demo (requires .NET 3.5 or later)
-
Force-based network visualization (31st January 2010)
"Visualizing a graph or network of interconnected nodes is a fascinating and important challenge with a wide variety of practical applications. This article looks at a simple but effective force-based approach to the visualization of networks and uses Windows Presentation Foundation (WPF) to display the results in real-time as they emerge. The result is a compelling interactive animation of the layout algorithm as it progresses..."
-
F# development with Visual Studio 2010 and .NET 4 (15th February 2010)
"Microsoft recently released Visual Studio 2010 Release Candidate (RC). The next release will be the official RTM so this is the perfect opportunity to see what improvements have been made to both Visual Studio, The .NET Framework and F# itself. Topics covered include recent changes to the F# language, F# integration in Visual Studio 2010, new functionality bundled in .NET 4 (including numerics and parallelism) and improvements in the CLR itself..."
-
An introduction to asynchronous workflows (28th February 2010)
"Asynchronous workflows were introduced into the F# programming language in 2007 and have recently matured pending the imminent release of the first officially-supported F# in Visual Studio 2010. This article describes the basic concepts that underpin this language feature and walks through some simple examples that demonstrate both basic and advanced use of this language feature..."
-
Writing an article editor with Windows Presentation Foundation (15th March 2010)
"This article describes the article editing tool we are creating to help automate the process of generating journal content. The editor provides a simple text editor where the author writes a form of markdown. The markdown is interactively parsed and pretty printed in a separate pane and the editor allows the result to be exported to HTML for inclusion in the journal. The application is based entirely upon Windows Presentation Foundation..."
-
An e-mail client in F# (31st March 2010)
"An e-mail client is an application that checks a remote mailbox for incoming messages and allows the user to send newly composed messages and replies to received messages. Incoming e-mails are typically read using the Post Office Protocol version 3 (POP3) which is a simple plain-text protocol implemented over TCP sockets. Outgoing e-mails are sent using the Simple Message Transfer Protocol (SMTP), an implementation of which is provided by the .NET framework. This article describes the design and implementation of an e-mail client that can be used for basic e-mail handling but, in particular, is easily programmed to perform tasks such as transaction processing automatically..."
-
The A* algorithm (15th April 2010)
"The A* algorithm is often used for route finding in game AI and is a generalization of Dijkstra's shortest-path algorithm from graph theory. This article describes two generic implementations of the A* algorithm written in F#. The first implementation is a simple prototype written in a purely functional style using data structures provided by F#. The second implementation uses mutable .NET collections to perform the same computation substantially more quickly. Finally, an example application is provided that finds a route across the Grand Canyon..."
-
Parallelizing the SciMark2 benchmark: part 2 (30th April 2010)
"The SciMark2 benchmark is one of the better benchmarks for programming languages and their implementations in the context of technical computing. This article is the second in a two-part series revisiting the SciMark2 benchmark to examine the parallelization of each of its component tasks. Specifically, the Monte-Carlo, sparse matrix-vector multiplication and LU decomposition tests. The results are of general interest in the context of improving performance on multicores using parallel programming..."
-
Quicksort (15th May 2010)
"The quicksort algorithm was invented by Tony Hoare in 1960 and remains one of the most celebrated algorithms and is still of great practical value. Implementing some of the many variations of the quicksort algorithm serves as an excellent introduction to mixed-paradigm programming in F# and the implementation of a production-quality implementation benefits enormously from the use of a substantial number of exotic features of the F# language. Moreover, the quicksort algorithm is amenable to parallelization, which is of increasing relevance in the multicore era, so the performance characteristics of parallelizations of the implementations are also of great interest..."
-
Cache oblivious algorithms: Matrix multiply (31st May 2010)
"The widespread adoption of CPU caches around two decades ago forced a change in the way programmers traverse data structures when performance is of interest. The classic style was to iterate directly using for loops. Two new styles have emerged: either a cache aware set of loops that tile the dataset into fixed-size subsets that fit into a cache of a known size, or a cache oblivious style that uses divide and conquer to subdivide the problem until it fits into the cache regardless its size. This article describes the revolutionary idea of cache oblivious algorithms via the elegant and efficient implementation of a matrix multiply in F#. In particular, we demonstrate the importance of these techniques in the context of multicore programming..."
-
Parallelism in .NET 4 and Visual F# 2010 (15th June 2010)
"The latest version of the .NET Framework provides a wealth of functionality for parallel programming aimed at multicores. This includes not only the Task Parallel Library, that was previously available in the form of CTP releases, but also Parallel LINQ (PLINQ) and the new concurrent collections. The F# standard library has also been augmented with parallelized functions. This article examines each of these in turn..."
-
The diff tool (30th June 2010)
"The unix program diff identifies differences between text files, line by line. This tool is most useful for comparing two versions of a program. This article develops a simple implementation of the diff tool based upon the longest common subsequence (LCS) algorithm with a graphical user interface written using Windows Presentation Foundation to visualize the difference between two text files..."
-
Histogram equalization (15th July 2010)
"Over- and under-exposed images have their intensity distributions skewed to the high or low end of the range. Histogram equilization is one technique to combat this effect digitally by spreading out the distribution of intensities in an image via the intensity histogram. This article describes a program for image enhancement using histogram equalization with an interactive WPF-based GUI using the new charting functionality in .NET 4 to visualize the intensity histograms in real time..."
-
Data structures: heaps (31st July 2010)
"A min-heap is a tree-based data structure that satisfies the constraint that the children at any given branch are always larger than their parent and, consequently, the minimum element is at the root. Heaps are most notable as an efficient way to implement priority queues which, in turn, underpin a variety of algorithms including some seen in previous F#.NET Journal articles. This article examines skew heaps, leftist heaps, pairing heaps and splay heaps..."
-
Calculator (15th August 2010)
"The pedagogical calculator sample demonstrates how a program can evaluate mathematical expressions originating from the user interface of a calculator. This article describes the design and implementation of a calculator application that uses Windows Presentation Foundation to provide a graphical user interface similar to that of a traditional calculator. In particular, every effort is made to leverage static checking in order to catch as many bugs at compile time as possible. This includes not only sophisticated union types to represent the state of the state machine but also exhaustiveness and redundancy checking of the advanced pattern matches that result as well as their factoring to reduce code size..."