Posts Tagged ‘F#’

Playing with F#

Sunday, November 16th, 2008

This little pretty window:

is a result of this tiny bit of F# code:

#light

open System
open Gtk

Application.Init()

let window = new Gtk.Window(“F# Gtk”)
let vBox = new Gtk.VBox()
let closeButton = new Gtk.Button()
let label = new Gtk.Label(“Hello World!”)

window.WindowPosition < – Gtk.WindowPosition.Center
window.SetDefaultSize(160, 40)
window.Destroyed.Add(fun _ -> Application.Quit() )

closeButton.Label < – “Close”
closeButton.Clicked.Add(fun _ -> Application.Quit() )

vBox.BorderWidth < – (uint32) 6
vBox.PackStart(label, false, false, (uint32) 6)
vBox.PackStart(closeButton, false, false, (uint32) 6)

window.Add(vBox)
window.ShowAll()

//brown paperbag update: I’ve missed this line during Copy/Paste
Application.Run()

Next step is piece of code that actually does something semi-useful. I’m thinking about implementing a convex hull algorithm which F# seems pretty well suited for.

Get Adobe Flash playerPlugin by wpburn.com wordpress themes