Day 11 – Testing your Times Tables with Perl 6

It’s nearly the end of Winter term at Elf Primary School near the North Pole. A keen head for figures is very important to elves, and the little elves’ numeracy teacher, Ms Hopper, wants to make sure they keep up their arithmetical skills right up to the penultimate day of term. (The last day of term is reserved for watching films and playing shove-ha’penny).

The little elves have just learned their times tables (multiplication tables) up to 12, but they aren’t all as good at it as they’d like to be, and some of them will be helping out in the toy workshops just before Christmas, when they may need to quickly tell the big elves how many more toys of a particular type to make.

Fortunately Elf Hopper is a very smart elf with an excellent head for figures – and code – herself. So she whips up a quick console app to run on the little elves’ school-issue Perlix 6.0 boxen.

The program allows the little elves to test themselves on their 2 to 12 times tables by just running it, or if they supply a single numeric argument, they can try out any multiplication table they like.

Continue reading “Day 11 – Testing your Times Tables with Perl 6”

Day 10 – jmp-starting your work flow

Here’s yet another version of jmp for you to unwrap before Christmas.

jmp is a command-line tool for searching through piles of code and then quickly jumping into an $EDITOR. This helps to keep things flowing.

Computer programming, however, has plenty of potential flow stoppers. To maintain a state of flow while coding you often need to quickly jmp to a line of code in other situations: fixing bugs, running tests, inspecting log files, checking git status etc. Can jmp help speed up these tasks too?

Continue reading “Day 10 – jmp-starting your work flow”

Day 9 – Let’s get astroPhysical! – Constants in Perl 6

I wrote my first Perl 6 program (that is, one that worked) the day before the London Perl Workshop where I proudly told people. So, JJ says “Why don’t you write an Advent calendar post for Perl 6?”

With only one program under my belt, what do I have to write about? Well … I authored Astro::Constants in Perl 5, so how hard would it be to migrate it to Perl 6?

Since I couldn’t keep my big gob shut, I give you the tale of a Perl 5 module author wandering through the Perl 6 landscape.

Continue reading “Day 9 – Let’s get astroPhysical! – Constants in Perl 6”

Day 8 — Make your Perl 6 grammar compact

Welcome to Day 8 of this year’s Perl 6 Advent Calendar!

Grammars are among many things that make Perl 6 a great programming language. I would not even try predicting the result of a poll to choose between grammars, Unicode support, concurrency features, hyper-operators, or the set syntax, or a Whatever star. Google found its own list of the best Perl 6 features published on the Internet.

Anyway, today we’ll be talking about Perl 6 grammars, and I will share a few tricks that I use to make the grammars more compact.

Continue reading “Day 8 — Make your Perl 6 grammar compact”

Day 7 – Automatic on a Cellular Level

Today’s advent calendar post deals with Cellular Automata.

What are cellular automata? I’m glad you asked! They are systems made up of only a few parts: A kind of field or “world” made up of cells, a set of states that every cell can be in at any point, a “neighborhood” describing what cells are visible to each cell, and a set of rules governing what a cell will change its state into given its own state and the state of all cells in its neighborhood.

That is, of course, a very abstract description, so let me give a few examples for the individual parts to hopefully give you an idea of what you might see in a cellular automaton:

In typical worlds you might find cells arranged like beads on a string, or like fields on a chess or chinese checkers board. There are also more exotic configurations you can make up: Any 2-dimensional field can be mapped onto any surface, like for example the Stanford bunny.

Continue reading “Day 7 – Automatic on a Cellular Level”

Day 5 – Variables

Such a simple thing, isn’t it? A variable is a name that holds a value.

Occasionally, the value it’s holding might be replaced by a different one — hence the name. (According to the surgeon general, variables that don’t experience change on a regular basis should see their physician, and ask to be diagnosed as constants.)

Even though they’re very easy to grasp, and basically every language has them, my goal today is to convince you that variables are actually wonderfully tricky. In a good way! I aim to make you stumble out of this blog post, dazed, mumbling “I thought I knew variables, but I really had no idea…”.

Towards the end, the experimental language 007 will also figure, because it’s completely and utterly this language’s fault that I’m thinking so much about variables.

Continue reading “Day 5 – Variables”