The demos in my F# talks use a number of coding snippets to acquire, generate and display data interactively. Some of these little snippets are not so well known, but they are useful :-)
One pattern is displaying tabular data interactively using a DataGrid view. For example, this is used to show the progressive results of
and can be used for just about any purpose where you need to quickly view tabular data.
The basic snippet is very simple, e.g. consider the following:
TopMost = true, Size = Size(600,600))
let data = new DataGridView(Dock = DockStyle.Fill, Text = "F# Programming is Fun!",
Font = new Font("Lucida Console",12.0f),
ForeColor = Color.DarkBlue)
data.DataSource <- [| ("http://www.bing.com",0);
data.Columns..Width <- 400
When run from F# Interactive, this displays a data grid as follows:
You can update the contents of the grid at any time by setting the DataSource property, normally just to some list of tuples.
For example, this is the result after updating with a list of tuples in the synchronous web crawl example (Tutorial\Intro Scripting\BasicIntroAndSyncWebCrawl.fsx) from the F# JAOO Tutorial I posted a few days ago, showing the initial pages reached by a depth-first crawl starting at the Google home page and the number of links found at each step:
[| for KeyValue(key,value) in visited -> (key,value.Length) |]
There are lots of other tricks you can play with grids from F# Interactive, and you can use them as the basis for very smart object displays. For example: