Monthly Archives: December 2010

You’ve likely seen postings already about how iOS device sales over the holiday influences app sales and related services, so I thought I’d share what happened with WOD since Xmas. In short, it’s good for me. The average over the past three days has been 50% greater than the average over the rest of December.

And, a pretty little graphic showing this:

I was just watching The Godfather, from a digital copy that I torrented totally downloaded completely legally, and you know there are some parts of the movie that are in Italian. This digital copy doesn’t seem to have English subtitles.

So what was the thought that entered my head?

“I should learn Italian so I’ll understand this.”

I am, you know, special that way.

Note, this is a start of this implementation, and I don’t consider it complete. In particular, I’d like it to take advantage of concurrency and Grand Central Dispatch in the future, and expand it to different kinds of sequences.

But anyway, I decided to give implementations of map, reduce, and filter for iOS development a try. Here we go.

First, let’s define some function block types:

typedef id (^MapBlock)(id);
typedef id (^ReduceBlock)(id, id);
typedef BOOL (^FilterBlock)(id);

This defines block types that (1) apply a function to an object, returning the result; (2) takes an accumulation as the first argument, the next object in the sequence as the second, and returns the next accumulation; and (3) is a simple predicate, which takes an object and returns a truth value based on that argument.

Now, let’s define a category for NSArray:

@interface NSArray (mapReduceFilter)
- (NSArray *) arrayByMappingWithBlock: (MapBlock) block;
- (id) valueByReducingWithBlock: (ReduceBlock) block;
- (NSArray *) arrayByFilteringWithBlock: (FilterBlock) block;
@end

And then, a straightforward implementation:

@implementation NSArray(mapReduceFilter)

- (NSArray *) arrayByMappingWithBlock:(MapBlock)block
{
    NSMutableArray *ret = [NSMutableArray arrayWithCapacity: [self count]];
    for (id value in self)
    {
        [ret addObject: block(value)];
    }
    return [NSArray arrayWithArray: ret];
}

- (id) valueByReducingWithBlock:(ReduceBlock)block
{
    id ret = nil;
    for (id value in self)
        ret = block(ret, value);
    return ret;
}

- (NSArray *) arrayByFilteringWithBlock: (FilterBlock) block
{
    NSMutableArray *ret = [NSMutableArray arrayWithCapacity: [self count]];
    for (id value in self)
        if (block(value))
            [ret addObject: value];
    return [NSArray arrayWithArray: ret];
}

@end

Cooking day again. Today I went for the “Transylvanian Stockpot” recipe, from page 44 of our current working manual.

Ingredients overview:

  • 6 oz. bacon.
  • One onion, three cloves garlic.
  • Paprika, black pepper, bay leaves and a cinnamon stick.
  • Cabbage.
  • 28 oz. can tomatoes.
  • 3 cups chicken broth.
  • Golden raisins.
  • Kielbasa sausage.

For whatever reason, Whole Foods didn’t have any golden raisins anywhere, and only had giant buckets of Thompson raisins. So, I went instead for some white figs, which worked great.

Cooking took a while, but was simple. Cook the bacon in a pot until the fat renders, and it starts to crisp. Add onion and garlic, and cook until the onion becomes transparent. Add chopped cabbage, paprika, pepper, cook briefly. Add tomatoes, broth, figs, cinnamon and bay leaves, and simmer for 45 minutes. Add sliced kielbasa and cook until the sausage is heated.

It’s good. Spicy, and a nice sweetness from the figs and the paprika. Nice and meaty with the bacon and the sausage. It also made a lot, meaning I’ll eat off of this one pot for at least three days. It took a while, but thankfully most of it was on autopilot, just waiting for the ingredients to simmer. These old-world recipes that feature vegetables like cabbage that have been cooked beyond any recognition as a vegetable aren’t my favorite, since I love the taste and texture of fresh, perfectly cooked vegetables, but it worked here as a good filler.

I’m enjoying these epically fragrant dishes!

★ ★ ★ ★ – (4/5)

Henceforth, my place in Santa Cruz shall be known as the “love nest.” Make note of this.

I have an oddly placed mirror.

Rainy day, about to get the keys to my new place.