I’m back blogging…
well, I at least have good intentions to do so. This post is mainly to see if windows live writer works ok to post to my blog!
Lets see…
I’m back blogging…
well, I at least have good intentions to do so. This post is mainly to see if windows live writer works ok to post to my blog!
Lets see…
let score_bowls bowls =
let rec score_bowls' frame l =
let nextframe = score_bowls' (frame+1)
match l with
| _ when frame = 11 -> 0
| [10;s] -> 10 + s + s
| 10 :: s :: n :: tail -> 10 + s + n + nextframe (s :: n :: tail )
| f :: s :: n :: tail -> f + s + (if((f+s)=10) then n else 0) + nextframe (n :: tail)
| _ -> List.fold_right (fun x y -> x + y) l 0
score_bowls' 1 bowls
let rec score_bowls bowls =
let rec score_bowls' frame l =
let sum b = (List.fold_right (fun x y -> x + y) b 0)
let nextframe = score_bowls' (frame+1)
match l with
| _ when frame = 10 -> sum l
| [10;s] -> 10 + s + s
| 10 :: s :: n :: tail -> 10 + s + n + nextframe (s :: n :: tail )
| f :: s :: n :: tail -> f + s + (if((f+s)=10) then n else 0) + nextframe (n :: tail)
| _ -> sum l
score_bowls' 1 bowls
#light
open System
open NUnit.Framework
let rec score_bowls bowls =
let rec score_bowls' frame l =
match l with
| _ when frame = 10 -> (List.fold_right (fun x y -> x + y) l 0)
| [] -> 0
| [f] -> f
| [f;s] -> f + s
| f :: s :: n :: tail when f = 10 -> 10 + s + n + score_bowls' (frame+1) ( s :: n :: tail )
| f :: s :: n :: tail when (f + s) = 10 -> 10 + n + score_bowls' (frame+1) (n :: tail)
| f :: s :: n :: tail -> f + s + score_bowls' (frame+1) (n :: tail)
score_bowls' 1 bowls
[
type BowlingTestCases = class
new() = {}
[
member x.SimpleScoring() = Assert.AreEqual(6, score_bowls [1;2;3] )
[
member x.ScoreSpare() = Assert.AreEqual(12, score_bowls [2;8;1] )
[
member x.ScoreStrike() = Assert.AreEqual(16, score_bowls [10;1;2] )
[
member x.ScorePerfectGame() = Assert.AreEqual( 300, score_bowls [for i in 1..12 -> 10] )
[
member x.SpareLastFrame() = Assert.AreEqual( 11, score_bowls ([for i in 1..18 -> 0] @ [2;8;1]) )
[
member x.StrikeLastFrame() = Assert.AreEqual( 21, score_bowls ([for i in 1..18 -> 0] @ [10;10;1]) )
end
good read... especially for C#ers :)
http://lucacardelli.name/Slides/2007-08-02%20An%20Accidental%20Simula%20User%20(ECOOP%20Prize).pdf

This is a bit off topic....but might be vaguely useful to someone if they manage to find it.
I recently bought Chessmaster 10th Edition. So I install it onto my Compaq nw8240. Its a reasonably beasty computer and should handle this fine. I go into some of the tutorial stuff, all seems fine. Then I starting playing in Training mode and something very curious happens. The game starts slowing down. Then freezes. Then I have to shut the computer down with a power off. The computer seems to be running really hot. So I try it again, same deal.
I leave it a few days and just do the "Academy" training stuff and the puzzles and things. But actually playing a game of chess seems to cause it to die. I figure for $25 it still is a pretty good deal, but I really would like to play chess! I have a copy of Pawn2 which is ok, but fairly limited.
So I ponder whether my computer getting really hot because the game is using a lot of CPU and the whole thing falling over is perhaps due to the inside getting too dusty.
So I hunt down some "Air Burst" (which I couldn't get at Dick Smiths, out of stock in two stores, but a Mitre 10 had truck loads of the stuff). I spray it into various vent on the computer, a bunch of dust comes out,
*spray* *spray* *spray* This is quite fun!
Get some tweezers and extract a few dust balls that just can't quite make it out the vents. Then I turn my computer on....run up chessmaster, and Ta Da! I can play chess. It runs really well. Great game!
Most surprised that actually made a difference!
I'm also noticing the fan doesn't turn on nearly as much when I'm using it now either... So something to keep in the back of your mind if your laptop seems to be running slightly hotter than usual!
Jetbrains have release a new version of Resharper.
This is simply a fantastic tool! Though, if you are new to resharper it can be hard to see why its so good. It's not until you see a Resharper Jedi at work do you really understand why people rave about it.
The real trick to it is learning / customizing the keyboard bindings and then letting them become second nature.
The second major trick is to go through all of the resharper goodies and all the options and customize the settings. Make your own live templates, your own file templates, bind it all to keys.
Now you can refactor your editing. Any time you duplicate any kind of action / typing, then chances are you can automate it with resharper. Never type a for loop again, learn the magic of Alt-Ins
It also helps with XML and XAML. Nice for WPF type development, though there's a heck of a lot more Resharper could do for XAML.
I've been actively playing with WPF and we are currently converting a "machine simulation" ( www.compacsort.com ) over to WPF. I really like it! It's not perfect, but its definitely a big step up from winforms.
I was browsing through...
http://www.orbifold.net/default/?p=713 (need a free ribbon like toolbar?) and he mentioned only around a 1000 people had downloaded kevins bag of tricks and that he was seriously worried about the future of WPF.
Well, I was one of those people to download it a while ago and was impressed with what you could do! so if you haven't already (only 1500 odd people at the time of this post), download from http://wpf.netfx3.com/files/folders/10297/download.aspx
If anyone else has links to good wpf resources, can you point me in the right direction? :-)
Just came across this today. I was just seeing how easy it is to mix winforms and wpf (completely simple). The only issues was it came up and said it didn't know what InitializeComponent() was. This is because it wasn't compiling the XAML. So...you need :-
<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />
in the project file (near the other similar looking import)
from the maker of Magic Ink.... http://worrydream.com/MagicInk/
