In my quest to have a mind-expanding experience this year, I'm learning functional programming. I've started with F# because of its great interop with existing .NET code. I just began my learning this weekend and thought I'd post a *simple*, but real-world example to help anyone else who is learning about F#.
Purpose of sample: List all the fonts installed on my system.
I've provided two samples: one in F# and one in IronPython to help anyone making the transition.
let ifc = new System.Drawing.Text.InstalledFontCollection()
let family_names = ifc.Families |> Array.to_list |> List.map (fun f -> f.Name )
do List.iter (fun f -> Printf.printf "%s\n" f) family_names
ifc = System.Drawing.Text.InstalledFontCollection()
fontnames = [font.Name for font in ifc.Families]
for fn in fontnames:
print "\"%s\"" % fn