Monthly Archive for November, 2008

Another F# sunday

So, another weekend, another F# excercise. This time I decided have some fun with Cairo inside Gtk# and a port of the old Knockout example from C# seemed like a prefect idea. Here’s what I got:

Compiled executable here, code here. Now, what I’ve done was pretty much a simple “translation” to get it running but I would love to make the code really functional. So, go headed and comment on what I could change to do it.


Another embarrassing udpate: fixed indentation


Update 2: indentation is broken by Wordpress editor. Code replaced with a link.

Playing with F#

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.

Sleepy…

…all the time. Here’s the reason:


Happy baby, originally uploaded by piotr zurek.


UA-1333993-1