|
Add elbenoblog to your friends list to get my distal wibblings in your friends page. Thanks to greatbiggary. |
|
Bye LJ
|
Jul. 28th, 2007 @ 12:01 am
|
|---|
|
Hello Wordpress.
This journal has moved. I've had enough of LJ - increasingly it's looking like last century's tech in terms of what I need. I'll keep the free account just to aggregate my friends pages. So I'll still be commenting on your LJs!
From now on, you can find me at www.elbeno.com/blog. I'm sure Wordpress will have its foibles, but at least I'll be able to do something about them. I won't be on your LJ friends pages any more. You can figure your own solution to reading/aggregating my blog, if you still want to. |
|
This is great. "Lucy at the River" is particularly inspired, I thought (also mirrored). |
|
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. |
|
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 |
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.
Jul. 17th, 2007 @ 05:37 pm
|
| » More on Tree Folds |
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).
Jul. 16th, 2007 @ 08:35 pm
|
| » Arboreal Haskell |
(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)
returns
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.
Jul. 15th, 2007 @ 07:49 pm
|
| » Book Sale Haul |
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
Jul. 14th, 2007 @ 01:48 pm
|
| » Harry Potter and the Order of the Phoenix |
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.
Jul. 11th, 2007 @ 09:24 am
|
| » Another Haskell question |
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?
Jul. 9th, 2007 @ 10:13 pm
|
| » Haskell problem followup |
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
Jul. 9th, 2007 @ 09:58 pm
|
| » Haskell problem |
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.
Jul. 7th, 2007 @ 10:48 pm
|
| » building a mame cabinet 7 |
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.
Jul. 7th, 2007 @ 04:01 pm
|
| » building a mame cabinet 6 |
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.
Jun. 30th, 2007 @ 09:55 pm
|
| » building a mame cabinet 5 |
Another stop at Home Depot this morning.
- DeWalt countersink bits
- Mallet (for knocking in the t-molding)
- Gloves
- Masking tape (for anti-splinter on the top side of ply cuts, and for painting)
- 4 x 2-1/2" hinges (two for the top, two for the front)
I'm now at the point where I can pick up some wood and sawhorses this weekend and get started.
Jun. 29th, 2007 @ 10:06 am
|
| » building a mame cabinet 4 |
I ordered the Retro Mame Marquee (third one down). With the Lexan sandwich. Since the Home Depot Lexan is 3/32" rather than 1/8", I decided I can't use it. I need to make the control panel from 1/8" Lexan and 5/8" MDF/Ply, so that the 3/4" t-molding will fit properly.
So what I'm going to do is get going with building the rest of it, and order the Lexan for the control panel from somewhere like Professional Plastics when I have the CP size finalised. I'll need to make sure I put the wood the right way up since the t-molding slot won't be symmetric, and my plan is to clamp the polycarbonate and wood together and drill them as a sandwich to ensure alignment.
Jun. 27th, 2007 @ 09:23 am
|
| » building a mame cabinet 3 |
I've been stopping off at Home Depot on my way to work and slowly getting together more parts. I now have:
- Jigsaw and router bit set (borrowed from a colleague)
- 4 x 2" industrial casters
- 1/2" wood chisel
- 18" drawer runner set
- Coin door! (free from a colleague)
- 140-tooth 7-1/4" ply/laminate saw blade
- 1lb 1" coarse thread drywall screws
I have also discovered that Home Depot stocks Lexan, which will save me having to order online and pay shipping etc. Unfortunately my spacious control panel design means that 18"x24" is a bit small one way. I have to bump to the next size, i.e. 48"x24". More expensive, but I can probably get a marquee sandwich out of that size as well as a CP cover.
I also have a 1/16" slot cutting bit on the way. The router bit set does not include one; however, it does include a flush cutter.
Jun. 26th, 2007 @ 10:46 am
|
|