Play Ball Script in F#

Scott Hanselman wanted an F# version of this Play Ball! round-robin scheduling PowerShell script. Here’s what I came up with:

let randomize list =
    let random = new System.Random()
    let list'=  
        list  
        |> List.map (fun i -> (random.Next(), i))
        |> List.sort (fun (i1,_) (i2,_) -> Int32.compare i1 i2)  
    let (_,list'') = List.unzip list'
    list''

let rec makeGames teams =
    match teams with
    | first :: rest ->
        [for team in rest -> (first, team)] @ (makeGames rest)
    | [] ->  []

let teams = ['a'..'f']
let games = teams |> makeGames |> randomize

MakeGames uses pattern matching to see if the list of teams is empty or not. If the list is empty, we simply return an empty list of games. If not, we use F#’s list comprehension syntax to generate a list of games between the first team in the list and each of the remaining teams. This list is combined (via the ‘@’ operator) with the results of calling makeGames recursively. This generates the un-randomized list of games.

Once we have the list of games, we need to randomize it. I ported the randomize function above over from a version I found in Erlang. Basically, it attaches a random number to each element in the list to be randomized, sorts by those randomly generated numbers, then throws the numbers away and returns the just the randomized list. Note, the Erlang version I referenced runs randomize log(length of list) times to ensure a fair shuffle, but I thought once would be enough for this simple script.

(Note to F# team: perhaps List.randomize should be a part of the standard F# library?)

Lunchtime Coffee 153

Morning Coffee 152

  • I was slammed Friday, so I didn’t get a chance to post the results of last Thursday night’s hockey game. I’m sure you’ve all been eager to hear. We lost, bad, 8-2. Personally, I was -3 and had no points, but I played much better than last week. We had three full lines of forwards, which was a big help, but I have started to find my ice-legs so to speak.
  • Charlie Calvert has the now-definitive list of LINQ to Everything. Of all of them, I found LINQ over C# fascinating, especially given my recent efforts in parsing.
  • Chris Tavares blogs about a distributed source control system called Bazaar. Unlike most version control systems, Bazaar is distributed which means you can use it without a server. According to Chris, you can share branches as easily as mailing a file. I wonder if you could make Bazaar work over a P2P network.
  • While looking up the MSDN link for the previous coffee item, I noticed an entire new section in the MSDN Library for Open Protocol Specifications. Not much to add, just wanted to highlight their existence.
  • Admitted non-designer Scott Guthrie shows off using the new version Expression Blend to build a Silverlight 2.0 app. Personally, I was most interested in seeing some of the new of built-in controls.

What is the ROI on EA?

Nick Malik took me to task for my suggestion that Enterprise Architecture provides no value.

You implied that I could not answer the question, “How does EA demonstrate value.” That is not true. I can readily answer the question, from my viewpoint, but I chose instead to *ask* the question to see if my answer matches the various answers that I may hear back. I got a lot of valuable input, both on the blog and on the forum on Shared Insights where I asked the same question.

You are the ONLY person to reply and say that EA provides no value.

Perhaps you should read about the role and value of Enterprise Architecture from established sources before you bash the entire profession.

EA is real, my friend. It is as real as city planning. The only major city in the US without city planning is Houston. I have visited a few times, and I can honestly say that without city planning, they are a mess.

Nick also provided a link to an article in Architecture and Governance magazine. I was going to read it, however their web site is down as I write this. I feel comfortable interpreting that as a sign that I’m right… 😄

Actually, Nick’s got a point. It was wholly unfair of me to say that EA provides no value. However, I do believe the return on investment of enterprise architecture is fairly low, perhaps even negative. In other words, I shouldn’t have argued that EA doesn’t deliver any value, but instead that I don’t think it delivers enough value, given what we spend on it.

Architecture ROI is hard enough to calculate on a project by project basis. I would argue that measuring it at the EA level is probably impossible, but I think that’s both a blessing and a curse. It’s a curse because EA can’t justify their existence in terms the business can understand. It’s a blessing because if EA is running as deep in the red as I suspect they might be, the company would cut EA entirely in a heartbeat.

Since Nick started my asking a question about value, let me turn it around and ask some questions of my own:

  1. How much do you think your organization spends on EA per year?
  2. What do you think your organization’s EA ROI is?
  3. What can you do to improve your organization’s EA ROI?

DevHawk’s Inessential List of Tools

ilanchelian left a comment yesterday asking for me to share some of the utilities that I use sometimes. Of course, Scott Hanselman keeps *THE* ultimate list of tools, hence my titling this list as “inessential” (note, it’s the list that’s inessential, not the tools themselves.)

But since you asked, here are some of the things kicking around my utilities folder (in no particular order):