Friday, July 25, 2008

F# for beginners

I'm trying to get some more breadth to my programming knowledge, so I decided to start looking into F# for some functional programming exposure.

So far, I'm liking what I'm going to call the brevity of the language. I'm not one of those people who thinks that programming languages ought to be made for the "Everyone" programmer, at least not all programming languages. It gives me the impression of condensing the programming down into little mouth-puckering shots of power, akin to some condensed tomato soup or something.

Anyway, to dig a little deeper into the language and actually try and solve problems I decided to try and do the beginner Scripting Games Events from this year in F#. There is already at least one post on another F# blog where someone is doing the first event.

I decided to try and limp through the second event, and here is what I came up with.


#light
open System
open System.IO
open Microsoft.Win32

// Scripting Games Event 2, How many True Type Fonts installed.

// Open the registry key where fonts are stored, using .Net objects
(Registry)
let fontKey =
Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Microsoft").OpenSubKey("Windows
NT").OpenSubKey("CurrentVersion").OpenSubKey("Fonts")

// Get the font names, convert to list
let vals = fontKey.GetValueNames() > Seq.to_list

// Defining a recursive "function" that takes a string to match and a list
of strings, returns num of matches
let rec matchEnd (srch : string) (list :
string List) =
match list with
[] -> 0 // Empty list
// The x and xs refer to the head(x) and tail(xs) of the list.
x::xs
when x.Trim().EndsWith(srch) -> (1 + (matchEnd srch xs))
x::xs ->
matchEnd srch xs

// Print the true type fonts, number of fonts, and total fonts.
List.filter (fun (b : string) -> b.Trim().EndsWith("(TrueType)")) vals
> printfn "%A"
printfn "True Type Fonts Installed: %A" (matchEnd
"(TrueType)" vals)
printfn "Total Fonts Installed: %A" vals.Length

// Pause for exit
Console.ReadKey(true)




Sorry for the lack of formatting (which is actually important for the #light syntax). So I think that does the job for Event 2. I'm sure it could be better, but it's just a learning exercise so far.

Friday, July 18, 2008

Deck Construction - Part 3 - Posts and Rails

We don't really have any pictures from the day we raised the posts and put the joists up. It was raining all day and it's just a blur now. Here is the current state of the deck.






So far, so good. Next steps, get the railings done and start the stair stringers.

Deck Construction - Part 2 - Solid Foundations

So the next phase of the deck is to put some solid foundations in place. After getting out some string and squaring everything up to the house, Brian and I rented a two-man Auger to drill 32" holes for our post bases. I don't really have any pictures of the holes, but here is the finished product with the concrete poured.

After getting the post holes dug and filling them with concrete, we attached to houseboard by using a hammer drill to drill 10" holes into the house. According to the inspectors, I couldn't just put lag screws into the board behind the brick, I had to go into the ends of the joists (dead-nuts so to speak). It was a pain in the butt, but we finally got all our holes lined up with the end of the joists and attached the board to the house with 10" Lag Screws.




Next step, putting up the massive 6x6 posts after we notch them for the beams.

Deck Construction - Part 1 - Destruction

So, in order to make a new deck, you have to get rid of the old one. Here is the old one.



Me (the flabby pale guy) and my brother (the skinny pale guy) decided to cut the joists that connect to the house board and pull the deck away from the house.


So far so good. Then we had to cut the pieces up into smaller more manageable pieces and haul them all to the dump to get rid of them. The Champagne Tacomastang made a pretty good wood wagon.