Archive for July, 2007

Harry Potter and the Order of the Phoenix

Wednesday, July 11th, 2007

Probably the best of the lot so far, even though it did cut a lot from the book. Mind you, the book had a lot of cuttable stuff, so that's not a bad thing. The film stuck to the plot well. A criticism perhaps is that the adult characters weren't really explored much, and perhaps it suffered from there being a bit too much that had to be cut out. Daniel, Rupert and Emma have really matured as actors. Other notable turns, I thought, were Evanna Lynch as Luna Lovegood and Helena Bonham Carter as Bellatrix Lestrange.

Also, The Golden Compass (Philip Pullman tie-in due out around Xmas) looks like one to watch out for.

Another Haskell question

Tuesday, July 10th, 2007

Which pattern is more efficient?

Pattern a:

circleSumA :: [Int] -> Int
circleSumA (i1 : is) = aux i1 is
    where aux i [] = i + i1
          aux i is = i + aux (head is) (tail is)

Pattern b:

circleSumB :: [Int] -> Int
circleSumB is = sum (is ++ [head is])

Is the Haskell compiler/interpreter able to make pattern b as efficient as pattern a? What about in the more general case where the operation is operating on more than 2 list elements? e.g. Folding a dot product over a list of points (obviously taking three points at a time to compute the dot product of the two vectors formed). In this case, Pattern b would have to perform 2 list appends (is ++ [head is] ++ [head (tail is)]). Would these get optimised?

Haskell problem followup

Tuesday, July 10th, 2007

Having read a bit of the next chapter and discovered the zipWith function, I now have a higher-order non-recursive solution to the makeChange problem, viz.

makeChange1 :: Int -> [Int] -> [Int]
makeChange1 amt vs = zipWith div modvs vs
    where modvs = scanl mod amt vs

Haskell problem

Sunday, July 8th, 2007

Define a function makeChange that, given a nonnegative integer amount and a list of coin denominations, returns a list of the number of coins of each denomination required to make up the amount. For example:

makeChange 99 [5,1] => [19,4]

i.e. 19 nickels and 4 pennies equals 99 cents. To make life easier, you may assume that the list of denominations is in descending order, and that the penny is always included.

I have the following, which works:

makeChange :: Int -> [Int] -> [Int]
makeChange _ [] = []
makeChange amt (v:vs) = n : (makeChange newamt vs)
    where n = amt `div` v
          newamt = amt - n * v

However, the problem is at the end of a chapter about using higher order functions like map, foldl, foldr, zip, etc. I have a feeling there’s a way to do this problem that way too. But it’s late and Mrs Elbeno is calling me to bed. AOAP.

Building a MAME cabinet 7

Saturday, July 7th, 2007

Just come back from a trip to Home Depot. I used the truck hire, which was easy. Now I also have 3 sheets of 4’x8′ 3/4″ oak ply in my basement, and I picked up a few 2″x3″x8′ studs too for cutting supports.

More wikihowery

Saturday, July 7th, 2007

Especially for . How to Find Headers and Libraries for C/C++ Pograms Using pkg-config.

I made a wikihow entry

Monday, July 2nd, 2007

How to Play Tiddlywinks.

Building a MAME cabinet 6

Sunday, July 1st, 2007

Today I was given some dedicated time by Mrs Elbeno to start the project. It being 2pm on a Saturday, I didn’t fancy my chances at getting a Home Depot truck hire (my local HD has 2 trucks and it’s first come, first served). Anyway, I headed down there and picked up:

  • 2x 8′ 2x4s
  • 2’x4′ 3/4″ MDF panel
  • 2 3′ lengths of 3/4″ pipe (for clamps)
  • 2 sawhorses
  • A t-square
  • A respirator (apparently MDF is hazardous to one’s health if inhaled)

Having loaded up the car, I headed home to make a start. I decided to make a sawboard as a mini-project which would be useful to familiarise myself with the power tools.
The inevitable flickr set has started.