Experiments in Programming

Here are some small experiment in programming. Nothing fancy, just something somebody could find slightly interested in checking.

GAP

The following are some simple functions and routines in GAP, a powerful package to make computations in algebra, and especially in group theory. I use these and similar pieces of code to test hypotheses during my research. For the definition of Parker vectors see for instance my PhD thesis. Inspired by the 99 Bottles of Beer on the Wall page (not maintained anymore, it seems), I wrote down the GAP routine beer.gap to spell out the lyrics of "99 Bottles of Beer on the Wall" ("99 bottles of beer on the wall, 99 bottles of beer on the wall / Take one down and pass it around, / 98 bottles of beer on the wall...").

C

This is perhaps more amusing for Italians. The names of Italian (or pseudo-Italian) restaurants out of Italy are often quite amusing or simply silly. As an exercise in programming, I wrote this simple C program, which tries to reproduce that kind of silliness, randomly assembling stuff as "Bella Mamma" or "Alfredo's Vesuvio". You will need a file like this (if something occurs: the words have to be one per line).

Awk etc.

I have also an amateurish interest in some topics of computational linguistics, so I studied something about "awk", a very useful tool for manipulating and elaborting strings and text files. Here is a small program I wrote. As it is, it is tailor-made to analyse a text file containing Dante's Divina Commedia (between a canto and the next one a "%" sign is inserted; each "cantica" -- Inferno, Purgatorio, Paradiso -- is separated from the next one by a "&" sign): it reads the poem and creates an index of all words therein, with indication of where they occur, in order of number of occurrences. To use it (in an unix-like environment): awk -f xxx.awk yyy.txt. A similar effect can be achieved in a number of other ways, among which this simple C shell script, using awk only marginally. I wrote it mostly to teach myself some useful Unix programs and commands (awk, tr, sort, uniq...). It enumerates words occuring in a text, and for each word multiplies its rank (its being the n-th most frequent) times its frequency (number of occurancies); this products should be somewhat constant, according to Zipf law.

Daniele A. Gewurz - Home page