Kean Walmsley posted an article describing how AutoCAD can be used to visualize a complete graph using vector graphics. This prompted Cay Horstmann to publish an article describing how the SPDE framework makes it possible to visualize the same thing using only 12 lines of Scala code. Here's how you can do the same thing in F# out-of-the-box in only 10 lines of code:
> #r "PresentationCore.dll";; > #r "PresentationFramework.dll";; > #r "System.Xaml.dll";; > #r "WindowsBase.dll";; > open System.Windows;; > let n = 24;; val n : int = 24 > let p i = let t = float(i % n) / float n * 2.0 * System.Math.PI Point(1.0 + sin t, 1.0 + cos t);; val p : int -> Point > let shape = Shapes.Polyline(Stroke=Media.Brushes.Black, StrokeThickness=0.001);; val shape : Shapes.Polyline > for i=0 to n-1 do for j=i+1 to n do Seq.iter shape.Points.Add [p i; p j];; val it : unit = () > Window(Content=Controls.Viewbox(Child=shape)) |> Application().Run |> ignore;;
When run from an F# interactive session, this program produces the following output:
Being able to solve simple problems simply and scale it up to sophisticated commercial software is why I love F#!