Adventures in Racket: gzip

In my research, I work with a lot of rather large text files–on the order of gigabytes if not terabytes per file. Since they’re plain text, they’re generally rather compressible though, so it makes sense to gzip them while they’re on disk. The drawback though comes when you’re working with them. There are a few options though.

read more...


Authorship attribution: Part 2

Last time, we used word rank to try to figure out who could possibly have written Cuckoo’s calling. It didn’t work out so well, but we at least have a nice framework in place. So perhaps we can try a few more ways of turning entire novels into a few numbers.

read more...


Racket Roguelike: Post-mortem

Almost four months ago, I started writing a series on how to write a roguelike in Racket. I believed then as I believe now that Racket is an excellent all around language and that I would like to see more done with it–particularly in games.

read more...


A programming puzzle: f(f(n)) = -n

Two Programming Praxis puzzles in a week? Madness! Let’s do it!

This time, the puzzle at first seems rather minimal:

Write a function f so that f(f(n)) = -n for all integers n.

If you haven’t seen this problem before, take a moment to think though it. It’s a neat little problem–a close cousin to a lateral thinking puzzle.

read more...


Racket Roguelike 9: Daedalus' wrath!

I think by now it’s well past time that we got to adding a bit more content. So far, here’s what we have (bolded entries we actually used in day 8):

  • entities: rat, goblin, bomb, bomber goblin
  • armor: leather, chain, plate, enchanted
  • weapons: club, dagger, battle axe, longsword, magic sword
  • potions: health potion
  • coins: copper, silver, gold, platinum
  • levels: forest, caves

We can do better than that though!

read more...


Swap list nodes

It’s been rather a while since I’ve worked out a Programming Praxis problem, but they posted a new one yesterday, so now seems as good a time as any. The problem is relatively simple:

Given a linked list, swap the kth node from the head of the list with the kth node from the end of the list.

Since all lists in Scheme are linked lists, that part seems easy enough. To make the problem a little more interesting however, I’m going to work it out in a purely functional manner: no mutation.

read more...