Archive for July, 2007

Media consumption

Tuesday, July 31st, 2007

Ben Board, my ex-colleague, good friend and co-conspirator in the realm of cryptic crosswords, has a gamasutra column/interview piece talking about his current media consumption.

By comparison, my media consumption (what a prejudiced phrase, but let’s go with it) is a bit more skewed towards books.

Sounds: Daft Punk‘s Discovery, Blur’s Modern Life is Rubbish and Weird Al‘s Straight Outta Lynwood have been on my playlist recently. I haven’t bought a CD in hmmm… over a year? Two years, perhaps? My morning commute music is KCRW‘s “Morning Becomes Eclectic”, which lately has been featuring Suzanne Vega and missFlag – their Hidden Thieves is quite good (and freely downloadable from their site).

Moving pictures: Almost none. Since I gave up on Heroes it’s been just the few times a week of watching Jeopardy during dinner. Moviewise, Mrs Elbeno and I are averaging a Blockbuster DVD about every two months; the last one we saw was Little Miss Sunshine. The company did treat me to a showing of Harry Potter and the Order of the Phoenix recently, but I haven’t visited the movies out of my own pocket in over two years, I think. When I first moved to the LA area I thought I should try to go to the movies more often, but then I thought that I don’t particularly like the moviegoing experience, and I don’t want to line the pockets of MPAA lawyers, so there you have it.

Words: I read a lot of technical material related tangentially to my job. I’m always a sucker for some geeky tome – at the moment I’m seriously into The Haskell School of Expression and also reading continually about Lisp and such topics as lock-free data structures. And of course I read Harry Potter and the Deathly Hallows on the day it came out.

Games: Since June, I’ve been rocking out to Guitar Hero I and II, and last weekend I returned to Twilight Princess on the Wii. I’m going to have to devote some more time to DS soon – I’m partway through Phoenix Wright: Ace Attorney and Mario & Luigi: Partners in Time, and I haven’t started on Hotel Dusk: Room 215, Puzzle Quest, or Contact. However, I have completed every Castlevania game on GBA and DS.

Building a MAME cabinet 8

Saturday, July 28th, 2007

I spent some more time on it this morning, after being too busy the last three weekends since I bought the plywood. Since I’m a power tool newbie, it’s going to take a while to complete. I learned a few things:

  • My sawboard was too thick, since I made it from 3/4″ MDF. I had to rout part of it at either end to be able to fit the clamps on properly.
  • One shouldn’t start routing from the side. Plunging is the correct way to do it. Going from the side too quickly caused the router bit to spring out and fly into my thigh. Luckily no harm done to self or router.
  • The ply blade was a definite win for getting decent cuts in the oak ply. I’m pleased with the results. But it may be dulling already – might need to pick up another one. I only got a cheap steel one.
  • It is pretty difficult to keep a jigsaw on a straight line, even with an edge guide. A circular saw is much easier. I’ll be making all my cuts with the circular saw now, just finishing with the jigsaw where I need to make joins or part cuts. Oh and I already had one jigsaw blade snap.

Everything is progressing, albeit at a slow pace. I have one side of the cabinet cut out, with a couple more cuts to complete to the monitor area. Somehow I sustained a small injury to my little finger knuckle, although I didn’t even notice that a chunk had been torn out until I was in the shower after finishing up for the day. Oh well.

Elbeno, now with 50% more everything

Saturday, July 28th, 2007

I just moved here from LiveJournal. All my LJ posts and comments have been migrated, thanks to some Perl & PHP wizardry. For now, this is the default WordPress theme.

Sgt Pepper Mashup

Friday, July 27th, 2007

This is great. “Lucy at the River” is particularly inspired, I thought (also mirrored).

Thinking about ditching LJ

Thursday, July 26th, 2007

And moving to WordPress. I already have hosting. LJ isn’t too reliable, actually, and it’s not nearly as flexible as WordPress would be. So… if I switch, I could still access friends pages here, but LJ denizens wouldn’t get me in their auto-aggregated friends pages.

Harry Potter and the Deathly Hallows

Sunday, July 22nd, 2007

I’ve just finished it, so I can now return to the Internet. Sorry for the delay – I’m in a late timezone to start with, and had to look after mini-Elbeno this morning.

Bye Bye Internet

Wednesday, July 18th, 2007

Apparently scans of Harry Potter and the Deathly Hallows have been leaked to Bittorrent. So I’m boycotting the Internet until I’ve read it.

More on Tree Folds

Tuesday, July 17th, 2007

After some thought, I think I have the definitions for left and right fold on a tree:

foldrTree :: (a -> b -> b) -> b -> InternalTree a -> b
foldrTree f z ILeaf = z
foldrTree f z (IBranch a x y) = foldrTree f (f a (foldrTree f z y)) x

foldlTree :: (a -> b -> a) -> a -> InternalTree b -> a
foldlTree f z ILeaf = z
foldlTree f z (IBranch a x y) = foldlTree f (f (foldlTree f z x) a) y

Of course, these folds are simplified: they don’t have a separate function for dealing with leaves and branches. This leads to things like flatten only working one way, i.e.
foldrTree (:) [] t
works because (:) will accumulate values onto a list properly from the right, but
foldlTree (:) [] t
gives a type error (because (:) cannot append a value onto a list working from the left).

Arboreal Haskell

Monday, July 16th, 2007

(Chapter 7 of The Haskell School of Expression is about trees.)

The first definition is of a tree with values stored only at the leaves, i.e.

data Tree a = Leaf a | Branch (Tree a) (Tree a)

It then gives a mapTree function (equivalent to map on a list), which is trivial, and functions fringe, treeSize and treeHeight, which return respectively the list of the leaf values, the number of leaves, and the max depth. In the text, these are defined in the usual recursive way. An exercise is to write a Tree equivalent of the fold function for lists. Which I think I managed:

foldTree :: (a -> b -> b) -> (b -> b -> b) -> b -> Tree a -> b
foldTree fLeaf _ init (Leaf x) = fLeaf x init
foldTree fLeaf fBranch init (Branch x y) = fBranch x' y'
    where x' = foldTree fLeaf fBranch init x
          y' = foldTree fLeaf fBranch init y

The trick was in recognising that I needed two functions, one for dealing with leaves and the other for dealing with branches (because (:) is a different type from (++) and both are used in fringe). Of course, the performance implication of all those list appends makes me think that in the real world, I’d write fringe using only (:):

fastFringe :: Tree a -> [a]
fastFringe t = acc t []
    where acc (Leaf x) l = x : l
          acc (Branch x y) l = acc x (acc y l)

(It also occurs to me that fringe is more usually called flatten IME). The next exercises involved trees with internal values (not at the leaves), i.e.

data InternalTree a = ILeaf
                    | IBranch a (InternalTree a) (InternalTree a)

This is a bit more like way I’m used to trees working, and the exercises were easier. InternalTree versions of zipWith and zip (defined in terms of zipWith of course) were easy, as were versions of take and takeWhile. I was impressed with the “magic” of the InternalTree version of repeat:

repeatInternalTree :: a -> InternalTree a
repeatInternalTree a = t
    where t = (IBranch a (t) (t))

There are two bits of magic here. First, this is an infinitely recursive definition. Haskell uses lazy evaluation, so this is designed to be used with takeTree or takeTreeWhile. The second piece of magic: where is the base case constructor (ILeaf) specified? It isn’t! Yet

takeTree 2 (repeatInternalTree 5)


IBranch 5 (IBranch 5 ILeaf ILeaf) (IBranch 5 ILeaf ILeaf)

as hoped for, if not quite expected. The only thing I’m not really grokking right now are the InternalTree versions of foldr and possibly foldl (and possibly a third type of fold). I’ve got a feeling there is some higher-order function extractable that controls pre-, post-, or in-order node traversal on InternalTree, but I’m unsure of the structural differences of foldl and foldr when applied to trees. I am also puzzling a bit over the semantics of zipWith and zip when applied to trees with only leaf-node values.

PS. Gleep = glorp.

Book Sale Haul

Saturday, July 14th, 2007

Today was the quarterly book sale at the Culver City library. The haul:

  • 16 Hardy Boys books
  • The Past Through Tomorrow – Robert A Heinlein
  • River Out of Eden – Richard Dawkins
  • Operating Systems Design and Implementation – Andrew Tanenbaum
  • The Design of the Unix Operating System – Maurice Bach
  • Introduction to Automata Theory, Languages and Computation – Hopcroft & Ullman
  • Mathematics for Dynamic Modeling – Edward Beltrami
  • Introduction to Parallel Computing: Design and Analysis of Algorithms – Kumar, Grama, Gupta & Karypis