Featured

The 2025 Raku Advent Posts

(in chronological order, with comment references)

Featured

All the blog posts of 2021

Featured

It’s that time of the year

When we start all over again with advent calendars, publishing one article a day until Christmas. This is going to be the first full year with Raku being called Raku, and the second year we have moved to this new site. However, it’s going to be the 12th year (after this first article) in a row with a Perl 6 or Raku calendar, previously published in the Perl 6 Advent Calendar blog. And also the 5th year since the Christmas release, which was announced in the advent calendar of that year.

Anyway. Here we go again! We have lined a up a full (or eventually full by the time the Advent Calendar is finished) set of articles on many different topics, but all of them about our beloved Raku.

So, enjoy, stay healthy, and have -Ofun reading this nice list of articles this year will be bringing.

Day 6 — Raku beyond Roast: what is enough?

There are two main sources from which you can learn the rules of the Raku programming language. The first is the official documentation. The second is the test suite called Roast.

An interesting thing about Roast is that if a Raku engine (an interpreter or a compiler) passes all the tests in Roast, it can be called a Raku implementation.

Any compiler that passes the tests is deemed to implement that version of the Raku specification.

Until recently, we had only one Raku engine, Rakudo. This year added two more implementations: Raku++ and mutsu. All three pass 100% of Roast.

In Roast, more than 220,000 individual tests are hosted in about 1500 files. There is also a spectest list, which includes 1425 file names that are the absolute minimum (in fact, the list excludes just a few files with not-yet-implemented syntax). Roast isn’t carved in stone and gets updates quite often, so make sure you git pull it from time to time.

Now that it’s already December, let’s look at what it costs a compiler developer to prepare a Raku engine and make sure it is released before Christmas. Let me share my experience here.

The first steps to pass Roast

Moving towards the 100% mark was one of the main initial tasks for the Raku++ compiler. The first implementation easily reached about 50-60%. Then another jump happened after implementing Unicode support, which made about 90k tests pass at once.

Getting from 90-95% to 100% took more time, but now the engine passes 100.00%. I intentionally write two zeros after the decimal point to indicate that the coverage is complete. With fewer digits, you could technically still have a gap of a few tests but fairly claim 100%.

A full Roast run (at the time of writing) includes 219,394 tests, and Raku++ fully passes it in about 30-40 seconds on a MacBook.

$ raku++ tools/run-roast.raku

The interesting part comes after you’ve reached the 100% bar. It turns out that many existing Raku programs still fail, and many modules from the ecosystem do not compile.

Are 220k tests really not enough?

Roast isn’t enough to ensure the compiler understands the whole language. To complement it, you need a deeper understanding of the rules. One such source is the official Raku documentation, from which you can extract code snippets and learn how language constructs must work.

So, on top of Roast comes the documentation. But that’s not enough either. I gathered all the programs and snippets I had written earlier for blog posts and books. That’s my Raku corpus. Another source of test programs is the vast archive of solutions to the Weekly Challenge, which has already been running for about than 8 years. Next, there are about 2500 Raku modules in the ecosystem.

Each source adds new use cases not covered by Roast or the documentation. The compiler must understand all of that.

A few more ideas came along. They are not yet fully implemented, but they have already helped to find and close more gaps. Below is an overview, maybe even a bit outdated 🙂

This is a simplified diagram of the Raku++ compiler ecosystem, with the compiler parts themselves and the various testing sub-projects around it. I won’t dig into it in this post, but you are welcome to explore the details.

Each section below describes a single initiative that I started to make the compiler better and to allow it to run more real-life Raku.

The Raku Corpus, a collection of real programs

The Raku Corpus is a collection of my own small programs that I wrote while working on different Raku projects, from books and the Raku Course to contributions to The Weekly Challenge. It contains about 1900 programs, and it helped to discover quite a few compiler gaps: grammar and Match (the biggest cluster), parse gaps (around 20 cases), glued -ne'…' flags (14), exceptions and exit codes (12), module-qualified calls, dates, slurpy hash issues, first(:k), and gists.

Later it became a check run against every larger change, and every week by Raku Eye (see below). Whatever it catches is cut down to a t/regression case, and that case goes into the gate.

Raku module battery with the ecosystem’s own tests

Being able to use modules submitted by Raku enthusiasts to the Raku ecosystem is one of the compiler’s main goals (which is obvious). The non-obvious part comes when you have reached full Roast coverage and some modules still cannot be compiled or run.

On the other hand, downloading modules from the Internet and running their code on your computer is risky. So I started with a battery of about 50 top modules. Surprisingly, a new factor popped up: the most popular modules use Rakudo internals. For example, to install a JSON-parsing module, you already need to be able to parse JSON, as the ecosystem index is a JSON file. Such chicken-and-egg problems are solved by embedding the required parts directly into the engine, which, in turn, makes a number of the most popular modules implementation-dependent.

No Roast test could predict that a new Raku engine must understand how to handle this name: Rakudo::Internals::JSON. Working with the top ecosystem modules is a good reality check. Nine of the top 200 modules call Rakudo::Internals. One module reads MoarVM’s object layout. JSON::Class refuses a compiler older than v2023.12, so Raku++ had to report Rakudo’s version. In total, about 500 of the first 4000 commits to Raku++ were about aligning these things.

Rakuglaze — module battery, but in seconds

Running the whole sweep over more than 2500 ecosystem modules takes a long time, and it’s mostly unnecessary for every release, as it does not catch new bugs. I had an idea to extract the most syntactically interesting parts from the modules’ sources and keep them both as a bug-finding test and as a set of regression tests.

This is what Rakuglaze (as in a shell over the modules) is. It is a collection that covers most of the ecosystem but can be run in seconds (and is most likely quite safe).

Each snippet contains a compilable piece of code and the expected result. For example:

=== list-kv-map-two-params
from: Getopt::Long 0.4.2 lib/Getopt/Long.rakumod:646
license: Artistic-2.0
feature: method kv
--- code
my @list = <file.txt out.txt>;
my @positionals = @list.kv.map: -> $index, $value {
"\$$index=$value"
};
say @positionals;
--- expect
[$0=file.txt $1=out.txt]

What it has caught so far: a try block is use fatal; $n max= *.elems curried the whole assignment; KEEP after a method’s Nil; Hash.push with a Slip; a list of an Array’s elements must write through to the array; say + (…) and f - 5 with f a declared sub; $*name interpolated in a regex; a type named Req read as reversed eq.

As you may notice from this dense description, the problems come when you combine the individual syntax elements. Each one may work well in Roast but break when it meets another part that works just as well on its own.

RakuGrid — element combinations as a matrix

And so we seamlessly come to the RakuGrid project, which aims to put isolated elements of syntax together in different possible combinations. The original idea was to make a matrix where the Raku ‘atoms’ sit along the axes, and the cells are thus combinations of two of them. Such two-item ‘molecules’ do actually find bugs. Additionally, corner cases such as -Inf, Inf, NaN, and -0e0 are added to the suite.

For example, one of the tests looks like this. Its combinational code is (2**64) - (1/3):

- id 0038
from ladder:numeric×numeric
cell 2**64 | 1/3
code (2**64) - (1/3)
is <55340232221128654847/3>
type Rat
oracle rakudo-2026.07 → <55340232221128654847/3>
oracle rakupp-v3.14.0-77-gf431f48-dirty → <55340232221128654847/3>

It may look trivial, but in reality it helps a lot. 2**64 is an Int, and 1/3 is a Rat, so here we test how these two combine and how the infix - handles them. The expected result is also a number of the Rat type. The exact digits in the stringified result must also agree.

Currently, RakuGrid contains about 170k tests with about 800 individual atoms. Testing with this suite allowed me to halve the number of failing grid cells in just a single day (from 9518 to 4930 on 16 August 2026).

RakuMap — generated programs shrunk to evidence

RakuMap, although its name may be confused with RakuGrid, is a different initiative. The core of the project is a code generator that creates small programs in 16 different domains: numeric calculations, containers, signatures, Unicode, regexes, phasers, concurrency, deliberately invalid code, etc.

Currently, there are about 200 programs, but that number should definitely grow. Let us look at one of the examples:

my @events;
{ LEAVE @events.push("leave"); @events.push("body") }
my $value = @events.Array;

This is a minimal program that, when run, must put the strings into the @events array in reverse order: $["body", "leave"]. All the programs print the main characteristics of the output using this similar boilerplate code:

sub safe-str($v) { my $s = try $v.Str; $s.defined ?? $s !! '<undefined>' }
say "TYPE\t" ~ $value.^name;
say "RAKU\t" ~ $value.raku;
say "STR\t" ~ safe-str($value);
say "BOOL\t" ~ $value.Bool;

In most cases, incorrect behaviour in a particular engine is discovered when its output differs from another engine’s output. And that brings us to the next problem.

Raku Behind the Docs and the need for a human in the loop

Rakudo can be considered a reference compiler, so when the documentation doesn’t answer a question and Roast doesn’t test it, Rakudo’s behaviour can usually be taken as the correct one. Usually, but not always.

Raku Behind the Docs was created as an educational project for readers who already know the Raku documentation and want to go further. But it also helped to find more bugs in the engine(s). It explains the things that the documentation doesn’t cover for one reason or another.

Every code example was run on both Rakudo and Raku++, and each difference was first treated as a potential Raku++ bug. But about 70 cases point the other way. These are the places where Rakudo’s behaviour may be worth a second look. Most of those cases can’t be settled mechanically, by AI or otherwise. Each one needs a human to decide what the right answer is.

Let’s examine a real case where this test suite helped to fix a tricky bug in Rakudo.

Can you tell what this one-liner should print?

say "abc".rindex(<a b>, 1);

The documentation describes rindex as taking two arguments. The first is the pattern, which may also be a List, but there is no example where both a list and a starting position (1 in the snippet above) are passed. Roast doesn’t test this combination either.

Let’s dig a bit into compiler internals. To see how Raku++ parses this code, use the --ast command-line option:

$ raku++ --ast -e"'abc'.rindex(<a b>, 1)"
Program
MethodCall │ .rindex
invocant:
StrLit │ "abc"
ArrayLit
StrLit │ "a"
StrLit │ "b"
IntLit │ 1

So, rindex gets a List as its first argument.

In Rakudo, you can use --target=ast to see the tree, or, better, ask for the RakuAST equivalent:

$ rakudo -e"say q{'abc'.rindex(<a b>, 1)}.AST"
RakuAST::StatementList.new(
RakuAST::Statement::Expression.new(
expression => RakuAST::ApplyPostfix.new(
operand => RakuAST::QuotedString.new(
segments => (
RakuAST::StrLiteral.new("abc"),
)
),
postfix => RakuAST::Call::Method.new(
name => RakuAST::Name.from-identifier("rindex"),
args => RakuAST::ArgList.new(
RakuAST::QuotedString.new(
processors => <words val>,
segments => (
RakuAST::StrLiteral.new("a b"),
)
),
RakuAST::IntLiteral.new(1)
)
)
)
)
)

Both compilers read the code the same way, so parsing isn’t the issue. The difference was at run time: in Rakudo, the call never returned because of an infinite loop in which the same multi-method was called again and again. That’s an easy corner to miss, as each half is tested separately and works on its own. Once discovered, the bug was fixed within a few hours, even faster than an AI would pick it up 🙂

This is exactly the kind of case a second implementation is good at finding. Two engines that disagree make you ask which one is right, and sometimes the answer helps both. The whole Raku galaxy wins.

FatRoast, the same Roast with fat added

This collection repeats the same Roast tests but with altered characters. Literally: wherever Latin letters stand, they are replaced with Cyrillic or CJK ones. In place of ASCII operators come their Unicode equivalents: ≤ ≠ × ÷ − ∈. The third branch changes the names: every declared variable, sub, class, role, and grammar is renamed.

Here’s one of the modified tests:

{
my $中 = '';
$中 ~= "|$_" for (<a b c> Z <X Y Z>).tree[];
is $中, "|a X|b Y|c Z", '(list of lists).tree';
}

Rakudo’s issue tracker as a test suite

Probably the most unexpected idea was to collect the code snippets from the issues that users have submitted to Rakudo’s GitHub repository.

More than 3000 issues have been submitted so far, and most of them are closed and resolved, so we know not only what was wrong, but also that it is now correct and how it behaves in the end. The snippets that are runnable (that is, not isolated fragments that you cannot compile without context) are first fed to Rakudo to get the expected result. The second phase is to run everything with your own engine.

If you agree that Rakudo is the de facto reference compiler, you get a great source of truth for your implementation. In the Raku++ repo, there are now about 100 commits prompted by this research.

In some cases, it was not only about correctness but also about performance. With Raku, one of the most difficult parts is lazy infinite lists and sequences like 1, 1, * + * ... *. For example, a series of 40k terms took 0.92 s before and 0.03 s after the fix (compared to Rakudo’s 0.07 s).

For the record, when you develop software with AI and fix very well-defined bugs, it is important to stop from time to time and do a round of generalisation. It helps to extend a fix that focused only on one narrow behaviour to a wide class of similar cases that nobody has reported yet: other spellings of the same operation, other methods of the same family, other types and other argument shapes. A precise bug report gets a precise fix, and the more exact the report, the narrower the fix tends to be.

The weekly Raku Eye

The weekly Raku Eye is a GitHub pipeline that runs every Monday, after the next batch of Weekly Challenge solutions has most likely landed in the repo. This tool runs them, as well as the new modules submitted to the ecosystem, with Raku++. It logs regressions and fixes, and it also runs the performance benchmarks, so it’s easy to track changes over time (although you have to be careful, as CI pipelines on GitHub do not always run under the same CPU conditions).

Performance tests

Before we wrap up for today, let’s continue with performance graphs. The tests in Roast only check whether the code runs correctly, but they don’t take into account how fast it compiles or how fast it runs. These parameters, though, may be crucial for real-life applications.

The most obvious parameter is execution time. It is less obvious how to measure it for isolated test cases. One possible solution is to create a collection of programs that are specially constructed to perform heavy computations.

Raku++ has such a collection in tools/bench. Each file is a short program that does one thing many times, so whatever an engine does slowly shows up in the total time. A few examples:

  • fib.raku: naive recursive Fibonacci fib(29)
  • objects.raku: creates 100,000 objects and uses their methods and attributes
  • multiwhere.raku: a multi-method with a where constraint, called 400,000 times
  • intcat.raku: a string built by appending a million integers to it: $s ~= $_ for ^1_000_000

The results are published in BENCHMARKS.md.

Mutsu has its own set of benchmark programs: grammars, JSON and YAML parsing, regexes, threads, Mandelbrot and more. Its CI runs them after changes, and draws the history as a trend chart.

Since 30 September, mutsu’s CI also runs Raku++ as a second reference implementation next to Rakudo. Every benchmark is timed on the same machine, and the chart can show mutsu’s speed relative to Raku++.

So two independent implementations now use each other as a measure of speed. Roast does not offer this, because it only checks that the answer is right.

It is worth mentioning that if an engine offers a profiler or stage statistics, those can also be used to draw some conclusions about performance. All three engines accept the --profile CLI option, whose results can be used in performance tests too. Rakudo and Raku++ additionally offer --stagestats.

Epilogue

What is described in today’s Advent post is not the final state of the global Raku test suite that I’d like to have by some Christmas yet to come. As you can see, I tried many directions. Some of them went further, and some are still at the proof-of-concept stage.

Altogether, it helped to make this year’s Christmas merrier.

Day 5  – Santa’s Checkwriter

Automating Check Writing

Santa’s finance department continued to modernize. It was updating the check writing process to satisfy new legal requirements around the world to increase the security of financial transactions. In doing so, the department required a method to automate check writing for U.S.A. vendors, thus the birth of the new Raku Checkwriter module. (which can also be used by private individuals).

NOTE: Other countries have greatly reduced check usage and to use one is very expensive, so only Letter size check paper is provided for. If other vendors need need other sizes they should file an issue at https://github.com/tbrowder/Checkwriter.

The first task was to design a check to be printed on the check paper stock. And that required selection of the paper which would be Letter sized and in two formats:

  1. One check at the top of the page (for single check generation)
  2. Three checks on the page (for bulk check generation)

Two sources of reasonably-priced suitable check paper were found at the stores linked below:

  1. Office Depot
  2. Check Depot

The elves tasked with the project started with the design of the checks in the original check book form as the starting point of the design to be used for the Checkwriter system. The existing dimensions of the current bank-issued checks’ bank routing number, the Santa Claus bank account number, and check number were used for the Checkwriter check design. (Note all zeroes are shown in the sample check below to prevent theft.)

Fonts for the check’s line of precise numerical data were investigated for automatic reading accuracy, and one suitable printer with magnetic ink source was selected from https://renewabletoner.com

Canon LBP122dw imageCLASS Check
Printer with 1 RT 071 MICR Cartridge $265.00
free shipping
as of 2026-11-15

At the same time, non-magnetic ink was tested with the same font to be used for other printers when necessary.

The font selected was the free and open-source Nimra-Regular.otf which is now embedded with Checkwriter.

The ultimate test was to see if a vendor could successfully cash a check produced by Checkwriter without the use of magnetic ink.

That was accomplished successfully, so the go/no-go test led to the other parts of the project: making it easily usable by other people or agencies.

Following is a copy of the default and sample check:

Sample check format

The system can also produce PDFs of a check register as shown in the following pdf:

The Checkwriter module can now produce single checks, but it is still under development. It will take some careful additions to do the following:

  1. Allow automated check writing with data coming from the accounting equipment.
  2. Allow automated data entry on the check registers.

Summary

The Checkwriter module can be a very merry gift to those who have trouble writing clearly on very tiny personal checks. Pair it with a signature stamp and check writing becomes a pleasure for old and young alike. Interested users are encouraged to observe the ongoing development and file issues for fixes or improvements.

Epilogue

Don’t forget the “reason for the season:” ✝

As I always end these jottings, in the words of Charles Dickens’ Tiny Tim, “may God bless Us, Every one!” [1]

Footnotes

  1. A Christmas Carol, a short story by Charles Dickens (1812-1870), a well-known and popular Victorian author whose many works include The Pickwick Papers, Oliver Twist, David Copperfield, Bleak House, Great Expectations, and A Tale of Two Cities.

Day 4 – Raku AI-agent Skills

Introduction

This document describes the creation and usage of the so-called skills for Artificial Intelligence (AI) agents in Raku programming sessions and workflows. (Agent skills for short.)

Agent skills became popular when the company Anthropic introduced them in the fall of 2025 as AI-agent-reusable folders containing a Markdown file named “SKILL.md” and sub-folders with scripts and references. “SKILL.md” starts with YAML-formatted header (with skill’s name, description, and optional metadata) followed by detailed instructions. AI-agents could discover those detailed instructions, and related scripts and references, through the so-called progressive disclosure.

Agent skills became prominent because the increasingly capable AI-agents could have access to tools via Model Context Protocol (MCP) or external function execution (aka “function calling”) but would not have the corresponding (reliable) know-how. Agent skills provide that know how.

Agent skills became very (explosively?) popular after Anthropic published the skill format as an open standard at agentskills.io.

This document covers several topics:

  • Well known collections of skills
  • A collection of Raku-centric skills
  • Practical tips of using AI-agents and skills
  • Demonstration (screenshot and comments)
  • Creation of AI-agent skills
  • Using Raku to validate Agent skills
  • Programmatic use of Agent skills
  • Future plans

Well known agent skills collections

There are multiple repositories of Agent skills. For example:

≈Stars Repository Description
338k mattpocock/skills Small, composable engineering skills (“for real engineers”). Includes grill-me, TDD, architecture, triage, etc.
331k obra/superpowers Full software development methodology (brainstorm → plan → TDD → subagent-driven implementation → review).
315k affaan-m/ECC Agent harness / performance system with skills, memory, security, and research-first practices.
204k anthropics/skills Official Anthropic reference repo with example skills + Agent Skills spec (includes document skills).
203k DietrichGebert/ponytail Encourages agents to write less, simpler, more minimal code.
157k nextlevelbuilder/ui-ux-pro-max-skill Design intelligence skill for better UI/UX (styles, color, typography, UX rules).
124k Leonxlnx/taste-skill Design / frontend taste skill for better-looking agent-built UIs.
122k addyosmani/agent-skills Production-oriented engineering skills covering spec-to-ship workflows with quality gates.
120k pbakaus/impeccable Design commands and vocabulary to polish and review UI work.
81k cloudflare/security-audit-skill Multi-phase security audit skill with machine-readable findings.
81k ComposioHQ/awesome-claude-skills Broad awesome-style list of Claude skills, resources, and tools.
79k mvanhorn/last30days-skill Researches recent topics across social and the web, then synthesizes a summary.
73k blader/humanizer Rewrites text to remove common signs of AI writing.
64k coreyhaines31/marketingskills Marketing skills: copy, SEO, CRO, analytics, etc.
38k VoltAgent/awesome-agent-skills Curated collection of 1000+ official and community skills (multi-agent compatible).

Remark: Star counts (from early December 2026) are approximate and change rapidly.
Remark: Review any skill’s contents — especially scripts — before installing!


A current collection of Raku-centric skills

The GitHub repository “Raku-Agent-Skills”, [AAr1], has 9 skills that facilitate Raku programming. (Currently, mostly for my own packages. This is how I test Agent skills over multiple agents: using packages I know well and use often.)

Here is a tabulated list:

SkillDescription
raku-functional-parsersParser creation with “FunctionalParsers”
raku-h2o-client-data-manipulationData wrangling with “H2O::Client”
raku-javascript-d3-plots-and-chartsPlots and charts with “JavaScript::D3”
raku-javascript-google-chartsPlots and charts with “JavaScript::Google::Charts”
raku-l10n-localizationsRaku keywords localizations to Bulgarian and Russian.
raku-literature-search-arxivarXiv literature search with Raku ecosystem packages.
raku-llm-graph-makingCreation of LLM-graphs provided by “LLM::Graph”
raku-number-theory-computationsNumber theory computations with “Math::NumberTheory”
raku-numerical-integrationNumerical integration computations with “Math::NIntegrate”

Here is a table of the three Agent skills repositories I have started:

Stars Repository Description
0 antononcube/Python-Agent-skills Curated collection of 1+ Python programming skills.
0 antononcube/Raku-Agent-skills Curated collection of 9+ Raku programming skills.
0 antononcube/WL-Agent-skills Curated collection of 1+ Wolfram Language programming skills.

Practical tips of using AI-agents and skills

Here is a list of practical tips on using AI-agents and skills for privacy or security point of view:

  • Strongly consider using AI-agents in Docker, Apple Container, DevPod, Fly.io, etc.
  • Determine do you want to use the AI-agent in a Terminal app via Command Line Interface (CLI) or over a certain Integrated Development Environment (IDE) app.
    • Below is a screenshot of using Docker image via Visual Studio Code on macOS.
    • Beware that your IDE might be “AI-agent enabled” and collecting telemetric data of you interactions.
  • Consider using AI-agents that easily connect to locally run models via llamafile or Ollama.
    • Prefer local or self-hosted model endpoints over cloud APIs for sensitive work
    • Verify that the chosen remote model provider does not retain or train on your prompts/completions
  • Consider using open sources agents (like Pi) instead of the “big tech” ones (like, Gemini, Claude, Codex, etc.)
  • Establish workflows for using Agent skills via programmatic invocation — as demonstrated below.
  • Run agents with the least privilege possible: mount only the specific directories.
  • Prefer ephemeral / throwaway environments.
  • Restrict network access.
  • Treat skills as untrusted code.
    • Review “SKILL.md” files and any accompanying scripts before installing or enabling them.
  • Keep secrets out of the agent’s context.
    • Never paste API keys, tokens, or passwords into prompts.
  • Version-pin both the agent and the skills you use, and periodically re-review them.
    • Skills and agent codebases can change — an update may introduce new tools, network behavior, or data-handling (which you might not like).

Demonstration

The following screenshot demonstrates the use of the AI-agent Codex in VS Code Dev container environment.

  • Examine the prompt at the top of the leftmost panel
  • Note that the first reasoning step shows the use of numerical integration skill (or guidance)
  • Also, a skill (or guidance) is found for the D3.js plot
  • The resulting notebook is a correct Jupyter notebook with correct executable Raku code
  • The rest of session screenshots can be seen here.

Creation of AI-agent skills

It is likely that prompt engineering is going to morph, or be replaced, by skills engineering. The “big” AI-agents (like Codex) have a skill to create Agent skills, therefore, often it is enough to provide a sufficiently good first version of the skill (name, description, know how, and optional scripts and references) and the ask the AI-agent to create full-blown Agent skill that adheres to the specifications and best practices given at agentskills.io.

This can be further facilitated by having procedures that validate Agent skills — i.e. check if a certain directory have the format described at agentskills.io.

For some of the Agent skills I created I did fairly extensive preparation. For example, for the skill raku-number-theory-computations I prepared programmatically a name-and-description table for all subs of “Math::NumberTheory”, [AAp4] — see the notebook “Math-NumberTheory-subs-table.ipynb”.


Using Raku to validate Agent skills

The package “LLM::Resources”, [AAp3], provides the class AgentSkillValidator for agent skill verification related operations (parsing, compatibility, validation) and the CLI script agent-skill-validation that checks whether a directory is a valid agent skill under the agentskills.io conventions.

Here is the usage message of CLI script agent-skill-validation:

agent-skill-validation --help
# Usage:
# agent-skill-validation.raku <skill-dir> [--boolean|--bool] -- Verify is a given directory a valid agent skill.
#
# <skill-dir> Agent skill directory
# --boolean|--bool Whether to give a Boolean results or not. [default: False]

Here is an example usage:

agent-skill-validation .
# [
# "Missing required file: SKILL.md"
# ]

The package “LLM::Resources” also provides the sub is-valid-agent-skill (used below).


Programmatic use of Agent skills

This section demonstrates how to use agent skills in Raku sessions via “LLM::Functions” framework, [AAp1].

Simple LLM-synthesis

Load packages:

use LLM::Functions;
use LLM::Resources;
use LLM::Prompts;

Get skill directories from a default location (“~/.codex/skills”) and print their names:

my $dir = $*HOME.add(<.codex skills>);
my @skill-dirs = dir($dir).grep(*.&is-valid-agent-skill);
.say for @skill-dirs».basename.sort
# raku-functional-parsers
# raku-h2o-client-data-manipulation
# raku-javascript-d3-plots-and-charts
# raku-javascript-google-charts
# raku-l10n-localizations
# raku-literature-search-arxiv
# raku-llm-graph-making
# raku-number-theory-computations
# raku-numerical-integration

Create an LLM access configuration that uses the AI-agent skills:

my $conf = llm-configuration('chatgpt', skills => @skill-dirs, max-tokens => 8192, model => 'gpt-5.6-luna', reasoning-effort => 'none');
# LLM::Configuration(:name("chatgpt"), :model("gpt-5.6-luna"), :module("WWW::OpenAI"), :max-tokens(8192), :prompts-count(1))

Generate an LLM result for a numerical integration computation command, [AA2]:

my $res = llm-synthesize([
llm-prompt('NothingElse')('Raku'),
'I want to compute the integral of 1/sqrt(x) over the range [0, 1] using Gauss-Kronrod rule.',
],
e => $conf
):!echo
# use Math::NIntegrate;
#
# my %result = nintegrate(
# -> $x { 1 / $x.sqrt },
# <x 0 1>,
# method => 'gauss-kronrod',
# precision-goal => 10,
# max-recursion => 20,
# :pairs,
# );
#
# say %result<integral>;
# say %result<error>;

Remark: The sub llm-prompt is provided by the package “LLM::Prompts”, [AAp2], which also has 233 prompts.

Remark: The echo adverb (boolean option) can be used to verify the use of skills.

The following diagram shows the three main stages of how llm-synthesize uses agent skills: (i) skill discovery and prompt generation, (ii) tool construction, and (iii) LLM configuration augmentation. It also shows the deferred loading of complete skill instructions.

The principal architectural pattern is progressive disclosure of agent skills:

  • Discovery: Only skill names and descriptions are initially collected.
  • Registration: The skills prompt and the activate-skill tool are added to the LLM configuration.
  • Activation: The LLM requests complete instructions for a relevant skill on demand.

Via a chat object

It is nice to have LLM-chat objects prompted to use AI skills (ready to be activated). Here is example code:

my $conf = llm-configuration('chatgpt', skills => @skill-dirs, max-tokens => 8192, model => 'gpt-5.1', reasoning-effort => 'none');
my $chat = LLM::Functions::Chat.new(llm-evaluator => LLM::Functions::EvaluatorChat.new(:$conf), chat-id => 'raku-skilled-chat-object-' ~ now.DateTime.Str);
say $chat.eval(llm-prompt('NothingElse')('Raku') ~ "\n\nCompute the primitive roots of 73.");

Future plans

This section lists possible Raku-projects for agent skill creation and facilitation.

Skills

A few months ago I made a call for Raku-centric skills. The (only) one suggested is obvious — searching Raku’s official documentation.

Here is a list of Raku Agent skills I see as both helpful to me and a “typical” Raku programmer:

  • raku-regression-workflows : Quantile Regression and Least Squares Fit computations.
  • raku-cli-file-search : “App::Rak” usage. ([AA1] shows how to use few-shot training.)
  • raku-doc-finder : Raku documentation search with correct web links.
  • raku-llm-pipelines: LLM pipelines created with “LLM::Functions” and “LLM::Prompts”.
  • raku-graph-creation-and-plottung : Graphs (networks) creation and plotting with “Graph” and “JavaScript::D3”.
  • raku-gui-making : most likely to be based on “GUI::Wings”.

And, yes, please feel free to suggest Agent Skills, and/or implement your own (and share with the Raku community.)

Integration

The following two integrations process the --skills option:

Those integrations are obvious and almost “immediate” given the chat-object-with-skills workflow demonstrated above. The reason they are not implemented yet is the dependence of “LLM::Resources” on the heavy “DSL::Translators”. (I plan to do those required refactoring and implementations soon.)


References

Articles, blog posts

[AA1] Anton Antonov, “TLDR LLM solutions for software manuals”, (2023), RakuForPrediction at WordPress.

[AA2] Anton Antonov, “Three Big Advancements in Raku Numerics”, (2026), RakuForPrediction at WordPress.

Packages

[AAp1] Anton Antonov, LLM::Functions, Raku package, (2023-2026), GitHub/antononcube.

[AAp2] Anton Antonov, LLM::Prompts, Raku package, (2023-2026), GitHub/antononcube.

[AAp3] Anton Antonov, LLM::Resources, Raku package, (2026), GitHub/antononcube.

[AAp3] Anton Antonov, Math::NumberTheory, Raku package, (2025-2026), GitHub/antononcube.

Repositories

[AAr1] Anton Antonov, Raku-Agent-Skills, (2026), GitHub/antononcube.

Day 3 – 6.e so near

Lizzybel was in a pensive mood at North Pole Central: “Who would have thought in 2018 that the next Raku language level would take more than 8 years to arrive?”.

It had been a year with many changes. Never before did it look like language level 6.e of the Raku Programming Language would actually happen in the coming months. It really felt like being between eras.

Thinking to herself, she made a list of the past year’s achievements:

Fixes to precompilation

For a long time synthetically built RakuAST code could not be used in a module that was being pre-compiled. This was a particularly nasty issue that needed some thorough research before it was fixed.

As soon as this was fixed, it was possible to “release” the re-imagined functionality of .assuming and sprintf, now based on building synthetic RakuAST trees. Rather than depending on string evaluation (in the case of .assuming) or parsing the format string with a grammar on every call (in the case of sprintf).

RakuAST capable of building Rakudo itself

The next step was having RakuAST be able to build the Rakudo core setting (in other words, the part of the Raku Programming language that is not purely written in NQP).

Before this, RakuAST could only run on a fully functional Rakudo built with the legacy backend. Being able to build the Rakudo core setting in RakUAST also meant being able to compile Raku code even if there’s no fully functional Rakudo yet. Bootstrapping is hard!

Make RakuAST the default build method

After making sure that all spectests would pass with RakuAST, and thoroughly checking the Raku ecosystem for problems occurring during testing and installation of a module with RakuAST, was the decision made to make RakuAST the default way of building Rakudo and running Raku programs with Rakudo.

Before this, Rakudo users that wanted to stay up-to-date with the latest Rakudo version, would be using the “legacy backend” by default and would need to opt-in to building Rakudo and/or running Raku programs with RakuAST.

The 2026.09 Rakudo release switched the default: so now one had to opt-out of using the new RakuAST based Rakudo. This produced some new bug reports from the ecosystem users, of which most were fixed in the 2026.11 Rakudo release.

Remove the legacy backend

The next step was of course removing the legacy backend.

“Such a simple click, so much work by giants removed”, Lizzybel thought to herself when she merged the “Remove the legacy backend” Pull Request the other day. With the work of more than 200 people from the earliest commit in 2006, until now. Without which RakuAST wouldn’t have been possible.

But also 30668 fewer lines in the Rakudo codebase to maintain and to compile every time one builds Rakudo! That’s a good thing for anybody involved in the development of Rakudo. This will be in the 2026.12 release of Rakudo.

Is all of that code really gone now? No, not really, it now just lives in an alternate reality called the “legacy-backend” branch.

Is it there yet?

In the middle of all of these contemplations, Nanunanu (one of the IT elves) entered the room enthusiastically as always and asked with a smile resembling a grin “Is 6.e there yet?”.

Lizzybel sighed at so much enthusiasm and said “No Nanunanu, but it’s not very far anymore”, thinking about Papa Smurf while withholding a grin herself.

Todo’s

“So what needs to be done still then?” asked Nanunanu. “Glad you asked”, said Lizzybel, “if we’re going for January 2027 for a 6.e language release, we would need to do the following as soon as possible:”

Providing a clear and documented RakuAST interface

The RakuAST bootstrap currently contains more than 500 RakuAST:: classes and roles, many of which could be considered implementation detail. It needs to be figured out which classes / roles are to be considered “public” (at least in the initial 6.e language level release), and which ones are internal.

And then the interface to these classes needs to be documented.

Migrating Rakudo tests to roast

Now that RakuAST is the only backend available in Rakudo, it has become de-facto part of the definition of the Raku Programming Language. Which means that all appropriate tests currently living in Rakudo now (about 472 files) need to be moved to roast, the test-suite for the bleeding edge for Raku development.

Just moving the files would be a simple solution, but many of these new test-files were created with the use of LLM’s and probably need some more thorough investigations before being added to the Raku specification test-suite.

Preparing for a marketing blitz

We want more people to start using Raku. With a major milestone reached, it is time to really let the people know that Raku is here and now and at a new level.

Wow

“Wow”, said Nanunanu, “a lot has been done in the past year, but a lot needs to be done still”. Lizzybel agreed. “And I probably forgot a bunch of other things that would still need doing. But that’s more general day-to-day stuff”.

“It’s nice that Santa allows me to work on this basically full-time, but help from the other IT elves, and maybe some marketing elves would be very welcome” she said, and continued with “I realize Santa’s has given them a lot of tasks already, but it still would be so nice if some of them would find some time to help out with this”.

“I’ll see if I can find some help”, said Nanunanu on the way out of the room, leaving Lizzybel with her thoughts.

The 2026 Raku Advent Posts

(in chronological order, with comment references)

Day 2 — Ringing in the Greetings

Using Raku++ to create website functionality

Gifts this year

Two talented Raku community members – Andrey Shitov and Tokuhiro Matsuno – have developed two new Raku compilers using Generative AI tools. Andrey‘s Raku++ is written in C++ and Tokuhiro‘s mutsu is written in Rust. Both offer ways to write Website functionality in Raku by clever leveraging of WASM. [ 1 ]

I consider both Raku++ and mutsu to be amazing gifts to the Raku community this year, so thank you to both Andrey and Tokuhiro.

Since I far prefer writing programs in Raku than in Javascript, I was excited to try one of the above to move functionality in the new documentation website to Raku.

The new Raku documentation website deployment is still being developed / tested, but both Raku++ and mutsu can be invoked in the website by clicking on the terminal icon on the right-hand side.

For the purposes of this article, I can only use one of these projects, and there is a lot of documentation to read. In addition, I have a bit more familiarity with C++ than Rust, so that slightly tilted my decision to use Raku++ for this test as I was expecting to need to look under the hood given the newness of the project. To be honest, there was never any need to look at the underlying code, so I offer my humble appologies to Tokuhiro for not choosing mutsu and I will look at it in the future.

Greetings in other languages

If you take a look at the new Raku documentation website, you will see a drop-down to select the UX language. The goal is to have Raku documentation in multiple languages, and for the UI language to be independent of the content language (current multi-lingual sites change both the navigation and content together which is a pain if you just want to check on some item in another language, but have to work out how to get to it in the other language).

Essentially all user-facing text is held in HTML spans with a key, and the web page is shipped with a map from from the language / key to the text to be used.

What I want to explore is how much of the functionality currently implemented in Javascript can be implemented in Raku, and whether there is a performance hit. Articles about WASM indicate that Javascript will be faster for this sort of functionality and that other language implementations in WASM will be faster for calculation heavy functionality, so this particular example should not have any performance benefit.

The existing implementation

The following is an HTML file with a stripped down version of the Javascript-only program (view it here).

Code1.

<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<title>Greet the world</title>
<script>
var dictionary = { "en": { "LangName": "English", "HappyBirthday": "Happy Birthday", "Congratulations": "Congratulations", "HappyHolidays": "Happy holidays" }, "uk": { "LangName": "Українська", "HappyBirthday": "З днем ародження", "Congratulations": "Вітаю", "HappyHolidays": "Зі святами" }, "cy": { "LangName": "Cymraeg", "HappyBirthday": "Pen-blwydd hapus", "Congratulations": "Llongyfarchiadau", "HappyHolidays": "Gwyliau hapus" }, "ja": { "LangName": "日本語", "HappyBirthday": "お誕生日おめでとう", "Congratulations": "おめでとう", "HappyHolidays": "楽しい休日を" }, "nl": { "LangName": "Nederlands", "HappyBirthday": "Gefeliciteerd met je verjaardag", "Congratulations": "Gefeliciteerd", "HappyHolidays": "Fijne feestdagen" }, "epo": { "LangName": "Esperanto", "HappyBirthday": "Feliĉan naskiĝtagon", "Congratulations": "Gratulojn", "HappyHolidays": "Feliĉajn feriojn" } };
</script>
<script>
function setUI( tSpans, newLang ) {
tSpans.forEach( function (elem) {
token = elem.getAttribute('data-UIToken');
elem.innerHTML = dictionary[newLang][token];
});
};
</script>
<script>
function makeUISelector( initial, selectorElem ) {
var options = '';
Object.keys(dictionary).forEach(function(key) {
isSel = key == initial ? ' selected' : '';
options = options +
'<option value="' + key + '"' + isSel + '>' + dictionary[key]['LangName'] + '</option>';
});
selectorElem.innerHTML = options;
};
</script>
<script>
var defLang = 'en';
var uiselector;
var token_spans;
document.addEventListener('DOMContentLoaded', () => {
uiselector = document.getElementById('Elucid8_ui-switch-contents');
token_spans = document.querySelectorAll('.Elucid8-ui');
makeUISelector( defLang, uiselector );
setUI( token_spans, defLang );
uiselector.addEventListener('change', (event) => {
newLang = event.target.value;
setUI( token_spans, newLang );
});
// placeholder for Raku link
});
</script>
</head>
<body>
<table style="border: medium groove black;">
<tr><td>Greeting language</td>
<td>Javascript: <select id="Elucid8_ui-switch-contents"></select></td></tr>
<tr><td>Greeting 1</td><td><span class="Elucid8-ui" data-uitoken="HappyBirthday">Greeting 1</span></td></tr>
<tr><td>Greeting 2</td><td><span class="Elucid8-ui" data-uitoken="Congratulations">Greeting 2</span></td></tr>
<tr><td>Greeting 3</td><td><span class="Elucid8-ui" data-uitoken="HappyHolidays">Greeting 3</span></td></tr>
</table>
</body>
</html>

Main components

The Javascript program has been split into four components between script tags:

📜 a dictionary which contains the three greetings and language name keyed by language and token
📜 code to generate the drop-down selection based on the languages in the dictionary
📜 code to replace the text of spans with the selected language
📜 code that runs when the DOM has settled, including a search to gather into an Array all the DOM elements containing spans that have tokens that need replacing.

Moving into Raku?

The first step is to move the dictionary to Raku (again this is nowhere near optimal given that the dictionary is simply a native Javascript object).

Apart from the hash definition, the Raku program is trivial. Let’s assume this is the content of a text file called r-funtions.raku:

Code2.

our %h =
en => %(
LangName => "English",
HappyBirthday => "Happy Birthday",
Congratulations => "Congratulations",
HappyHolidays => "Happy holidays",
),
uk => %(
LangName => "Українська",
HappyBirthday => "З днем народження",
Congratulations => "Вітаю",
HappyHolidays => "Зі святами",
),
cy => %(
LangName => "Cymraeg",
HappyBirthday => "Pen-blwydd hapus",
Congratulations => "Llongyfarchiadau",
HappyHolidays => "Gwyliau hapus",
),
ja => %(
LangName => "日本語",
HappyBirthday => "お誕生日おめでとう",
Congratulations => "おめでとう",
HappyHolidays => "楽しい休日を",
),
nl => %(
LangName => "Nederlands",
HappyBirthday => "Gefeliciteerd met je verjaardag",
Congratulations => "Gefeliciteerd",
HappyHolidays => "Fijne feestdagen",
),
epo => %(
LangName => "Esperanto",
HappyBirthday => "Feliĉan naskiĝtagon",
Congratulations => "Gratulojn",
HappyHolidays => "Feliĉajn feriojn",
),
;
sub rDictionary( $lang, $token ) is export {
%h{$lang}{$token}
}

After installing the raku++ compiler as described in Install raku++ , we compile this to a Javascript file called rFunctions.js as follows

Code3.

    raku++ -o rFunctions.js --js --standalone r-functions.raku

Notes:

📜 The raku++ version must be > 5.11.0.
📜 The rFunctions.js file needs to be served to the webpage, so the source used below is from a github repo via a cdn (directly sourcing from github runs into a NoSniff error).
📜 The options for raku++ are given in more detail in the project’s documentation, however
▹ -o is the output (compiled) file name;
▹ –js indicates the compilation target;
▹ –standalone indicates only one file is to be created; and
▹ the final option is the input file name
📜 Note the is export trait on the Raku function, which magically allows it to be used within a Javascript program. This piece of magic really makes life easy.

In order to link the Raku to the webpage, we add two scripts into the document head section, namely

Code4.

 <!-- this should read '<script' but WordPress forbids it --> 
   src="http://cdn.jsdelivr.net/gh/finanalyst/Advent2026_Articles/rFunctions.js">
</script>
<script>
    function rSetUI( tSpans, newLang ) {
        tSpans.forEach( function (elem) {
            token = elem.getAttribute('data-UIToken');
            elem.innerHTML = rDictionary(newLang,token);
        });
    };
</script>

The github repo containing the sample output pages and the rFunctions.js also contains the RakuDoc source of this article.

In addition, we add the following in place of the comment // placeholder for Raku call.

Code5.

ruiselector = document.getElementById('rElucid8_ui-switch-contents');
rtoken_spans = document.querySelectorAll('.r-Elucid8-ui');
makeUISelector( defLang, ruiselector );
rSetUI( rtoken_spans, defLang );
ruiselector.addEventListener('change', (event) => {
newLang = event.target.value;
rSetUI( rtoken_spans, newLang );
});

Finally the table needs another column for the Raku greetings.

Code6.

<table style="border: medium groove black;">
<tr><td>Greeting language</td><td>Javascript: <select id="Elucid8_ui-switch-contents"></select></td>
<td>Raku: <select id="rElucid8_ui-switch-contents"></select></td></tr>
<tr><td>Greeting 1</td><td><span class="Elucid8-ui" data-uitoken="HappyBirthday">-</span></td><td><span class="r-Elucid8-ui" data-uitoken="HappyBirthday">-</span></td></tr>
<tr><td>Greeting 2</td><td><span class="Elucid8-ui" data-uitoken="Congratulations">-</span></td><td><span class="r-Elucid8-ui" data-uitoken="Congratulations">-</span></td>
</tr>
<tr><td>Greeting 3</td><td><span class="Elucid8-ui" data-uitoken="HappyHolidays">-</span></td><td><span class="r-Elucid8-ui" data-uitoken="HappyHolidays">-</span></td>
</tr>
</table>

The new page

Populating DOM elements from within Raku

In order to introspect the DOM of the HTML file, and to modify it, raku++ has the use js pragma. The pragma creates a new JS object, which can then be treated as the global This.

We add the following function to our r-functions.raku file:

Code7.

use js;
sub changeLang( $new-lang, $tag-class) is export {
my $doc = JS.document;
my @targets = $doc.querySelectorAll( $tag-class );
for @targets -> $elem {
my $token = $elem.getAttribute('data-UIToken');
$elem.innerHTML = %h{ $new-lang}{$token};
}
}

Then we replace the snippet in Code5 with

Code8.

ruiselector = document.getElementById('rElucid8_ui-switch-contents');
makeUISelector( defLang, ruiselector );
changeLang( defLang, '.r-Elucid8-ui');
rSetUI( rtoken_spans, defLang );
ruiselector.addEventListener('change', (event) => {
newLang = event.target.value;
changeLang( newLang, '.r-Elucid8-ui');
});

Moving the selector creation to Raku

Now we take the final step by populating the language selector from the keys of the hash, and attach a listener to the selector all inside a Raku function.

We add a new Raku function to r-functions.raku, namely

Code9.

sub setSelector( $selectorElem, $tag-class, $initial ) is export {
my $doc = JS.document;
my $sel = $doc.getElementById( $selectorElem );
my $options = [~] %h.map({
'<option value="' ~ .key ~ '"' ~ { .key eq $initial ?? ' selected' !! ''} ~ '>' ~ .value<LangName> ~ '</option>'
});
$sel<innerHTML> = $options;
changeLang( $initial, $tag-class );
# set up Event listener on selector
$sel.addEventListener('change', -> $el {
my $new-language = $el.target.value;
changeLang( $new-language, $tag-class );
});
}

Now the entire snippet in Code5 can be replaced with

Code10.

setSelector('rElucid8_ui-switch-contents','.r-Elucid8-ui', defLang );

And the result can be viewed here.

Some concluding remarks

After reading online tutorials about WASM, I was expecting a far more complex problem, and I planned this article to have very simple steps, sticking very closely to the Javascript version.

In the end, it was remarkably easy, and I now look forward to replacing other Javascript functionality with Raku functions, especially when regexen are needed. Compared to the elegance and simplicity pf Raku’s regexen, Javascript’s are quite horrific.


Footnotes

1 |^| I believe that the original intent was for Rakudo to offer a similar sort of backend, but development of that initiative preceeded the work on WASM, and the run time model for Rakudo was inherently multi-threaded, while Javascript in a browser is robustly single-threaded. No doubt this will change.

Day 1 — Chasing the Moon

Views of the Moon and Artemis II using JPL Horizons data and 3D plots made with Raku and D3.


Why the Moon is usually approximately known

The Moon’s orbit is nearly circular and nearly flat, which makes its motion predictable and easy to model. However, its orbit is slightly elliptical (stretched out) and inclined (leaning), and it interacts with the Earth’s tilt, Earth’s rotation, and Earth’s axial tilt. These subtle forces affect its path and are not fully captured in simple approximations. Because the Moon is a satellite of Earth, its motion depends on Earth’s position in space, and Earth’s orientation relative to the Sun also plays a role. Even though the Moon’s motion is consistent, these complex interactions mean that while the orbit is roughly understood, precise predictions require detailed data and advanced calculations.

Consequently, an ephemeris (table or diagram) can predict the Moon’s centre at a specified time and reference frame.

In this document we use Jet Propulsion Laboratory (JPL) Horizons System via the Raku package “WWW::HorizonsEphemerisSystem”.


Why landing is harder than finding the Moon

Landing on the Moon is hard because:

  • The Moon’s orbit is nearly circular but slightly elliptical and inclined, making its position unpredictable.
    • The Moon is small, distant, and variable, so locating it is tricky.
    • The Moon’s tilt and interaction with Earth’s rotation affect its movement.
  • Landing requires knowing the lander’s position, velocity, attitude, and fuel margin, not just the Moon’s center.
  • The spacecraft must cancel orbital speed at the right time, estimate height and horizontal velocity during descent, and land in a safe area.
  • Craters, slopes, rocks, dust, and low-angle sunlight or permanent shadows complicate camera-based navigation and hazard detection.
    • Local gravity variations affect landing stability.

In other words: a good ephemeris gets a spacecraft to the neighborhood; onboard navigation and guidance make a touchdown safe.

Artemis II was not a landing mission. It was a crewed Orion systems and operations test flight around the Moon and back. (Landing challenges are included here to show the “big picture” of flight trajectory calculations.)


Libration is a different kind of motion

The Moon rotates once per orbit, so it keeps nearly the same face toward Earth. Yet it appears to nod, roll, and turn slightly: this is libration.

To summarize:

  • Longitude libration: The elliptical orbit slows the Moon’s forward motion, causing tiny shifts in the direction it appears to move.
    • While Moon’s elliptical orbit changes orbital speed, its spin rate stays nearly steady.
  • Latitude libration: The Moon’s tilted orbit reveals different parts of its poles.
  • Daily effect: Our changing position on Earth adds small daily variations.
  • Key point: Libration does not cause large-scale wobble in the Moon’s path—it alters how we see it.

Horizons and Artemis II

NASA JPL’s Horizons system generates time-tagged positions, velocities, observing geometry, and related ephemerides for solar-system objects and selected spacecraft. The Raku package “WWW::HorizonsEphemerisSystem” wraps its web API; “JavaScript::D3” renders the results in a Jupyter notebook.

Artemis II launched on 1 April 2026 and returned on 10 April after a roughly ten-day crewed free-return flight.

The mission:

  • Tested Orion and its crew operations in high Earth orbit
  • Used trans-lunar injection
  • Made trajectory-correction burns as needed
  • Flew past the Moon
  • Returned for Pacific splashdown.

The free-return design used the Earth–Moon gravity field to provide a return path; it was a safety-minded trajectory (not a lunar landing).

Remark: NASA’s mission report and return announcement give the mission chronology.


Setup

The following code loads packages, setups visualization variables, and primes the Jupyter notebook for rendering JavaScript plots.

use WWW::HorizonsEphemerisSystem;
use JavaScript::D3;
use Data::TypeSystem;
use Data::Translators;
my $background = '#1F1F1F';
#% javascript
require.config({
paths: {
d3: 'https://d3js.org/d3.v7.min',
d3_3d: 'https://unpkg.com/d3-3d@2.0.2/build/d3-3d'
}
});
require(['d3', 'd3_3d'], function(d3, d3_3d) {
window.d3 = d3;
window.d33d = d3_3d || window.d33d || {};
});

Query and plot

The following queries use Horizons identifiers 301 for the Moon and @-1024 for Artemis II, with 399 (Earth) as the coordinate centre.

# Start, stop, and sample interval accepted by Horizons.
my @dates = (
'2026-04-02 01:58:33',
'2026-04-10 23:50:00',
'10 m',
);

Get Artemis II (@-1024) trajectory data:

my @artemis-position = horizons-ephemeris-data(
'state',
['@-1024', { center => '500@399', :@dates }],
'position',
:modifier<data>,
);
say "Artemis samples: {@artemis-position.elems}";
# Artemis samples: 1284
my @field-names = 'Calendar Date (TDB)', 'Date', 'X', 'Y', 'Z', 'Vx', 'Vy', 'Vz';
@artemis-position.head(5)
==> to-html(:@field-names)
Calendar Date (TDB)DateXYZVxVyVz
A.D. 2026-Apr-02 01:58:33.00002461132.582326389-24443.80199178298-14325.58855143395-1284.412074714483-1.84378694177628-3.873575971779941-0.3363757692828204
A.D. 2026-Apr-02 02:08:33.00002461132.589270833-25477.97645857157-16605.64195875344-1482.365439091096-1.609707947664253-3.728201914522506-0.3235391881935878
A.D. 2026-Apr-02 02:18:33.00002461132.596215278-26382.28882905463-18801.2477647928-1672.795463009787-1.409915601240013-3.592010346881853-0.3113824293486602
A.D. 2026-Apr-02 02:28:33.00002461132.603159722-27175.36803563279-20917.77703972007-1856.184939615227-1.237742849751446-3.464458414718095-0.3000428511459925
A.D. 2026-Apr-02 02:38:33.00002461132.610104166-27871.9413684281-22960.16420384998-2032.991346524761-1.087424309060239-3.344738598039487-0.2894257308463439
sample ephemeris data

Each record has X, Y, and Z in kilometres. This first plot is Artemis II alone, relative to Earth.

#%js
js-d3-list-line-plot3d(
@artemis-position.map(*<X Y Z>),
:$background,
box-ratios => Whatever,
:900height,
:900width,
:axes,
:!boxed,
)

Get Moon’s center @301 trajectory:

my @moon-position = horizons-ephemeris-data(
'state',
['@301', { center => '500@399', :@dates }],
'position',
:modifier<data>,
);
say "Moon samples: {@moon-position.elems}";
# Moon samples: 1284

Combined Earth–Moon–Artemis II plot

Every vector below has center => '500@399'. Therefore the Earth marker is stationary by construction; the plot shows the Moon and spacecraft relative to Earth.

#%js
my @combined = (
[0e0, 0e0, 0e0, 'Earth', 'point'],
|@moon-position.map({ [|$_<X Y Z>, 'Moon', 'line'] }),
|@artemis-position.map({ [|$_<X Y Z>, 'Artemis II', 'line'] }),
[|@artemis-position.head<X Y Z>, 'First Artemis sample', 'point'],
).map({ <x y z group type>.Array Z=> $_.Array }).map(*.Hash);
js-d3-list-point-plot3d(
@combined,
background => $background,
width => 800,
height => 800,
title => 'Earth-centered trajectories: Moon and Artemis II',
:20title-font-size,
box-ratios => Whatever,
:boxed,
:!axes,
:!ticks,
color-scheme => <SteelBlue Silver Pink Red>,
)

Point of view of the chased

With similar code we can produce a Moon-centered plot:

Remark: It can be seen from the plot that Earth rotates counter-clockwise from Moon’s perspective.


Leftover comments

  • For interactive graphics download and run the corresponding notebook, [AAn1].
  • This document closely follows the Wolfram notebooks [JBn1, JBn2] authored by Jeffrey Bryant on the same subject.
  • The JPL Horizons data retrieval and 3D graphics of this document were used to develop and test elements of the packages “WWW::HorizonsEphemerisSystem”, [AAp1], and “JavaScript::D3”, [AAp2].

References

Notebooks

[AAn1] Anton Antonov, “Chasing the Moon”, (2026), RakuForPrediction-blog at GitHub/antononcube.

[JBn1] Jeffrey Bryant, “Artemis II trajectory: crewed lunar flyby to launch on April 1, 2026”, (2026), Wolfram Community.

[JBn2] Jeffrey Bryant, “View of the Moon from Artemis II”, (2026), Wolfram Community.

Packages

[AAp1] Anton Antonov, WWW::HorizonsEphemerisSystem, Raku package, (2026), GitHub/antononcube.

[AAp2] Anton Antonov, JavaScript::D3, Raku package, (2022-2026), GitHub/antononcube.

Sources

Day 25 – Raku 2025 Review

How time flies. Yet another year has flown by.

Let’s first start with the technical stuff, as nerds do!

Rakudo

Rakudo saw about 1650 commits (MoarVM, NQP, Rakudo, doc) this year, which is about 20% less than 2024. All of these repositories now have “main” as their default branch (rather than “master”).

About 58% of the Rakudo commits were in the development of RakuAST (up from 33% in 2024), of which more than 95% were done by Stefan Seifert. This work, that was supported by a TPRF grant, resulted in being able to build the part of Rakudo that’s written in Raku using RakuAST (often referred to as the “bootstrap“).

However there are still quite a few issues that need to be fixed before RakuAST-based Rakudo can be made the default. And thus be ready for the next language level release. Still, an amazing amount of work done by Stefan Seifert, so kudos!

Under the hood, behind the scenes

Geoffrey Broadwell has done a major update of the internal MoarVM Unicode tools. Based on that work Shimmerfairy developed an update of the MoarVM Unicode support from 15.0 to 17.0. This includes support for some new emojis such as FINGERPRINT 🫆, SPLATTER 🫟, HARP 🪉. This means that all of the changes of Unicode 16 and Unicode 17 were implemented to a very high degree. Quite a feat!

Patrick Böker was really busy this year: new script runners not only made execution of CLI-scripts a bit faster, it also made it possible to run CLI-scripts on Windows without any issues.

Again, a lot of work was done on making the Continuous Integration testing produce fewer (and recently hardly any) false positives anymore. Which makes life for core developers a lot easier!

Very important for packagers: Rakudo now again has a reproducible build process, thanks for Timo Paulssen and others.

Also the REPL (Read, Evaluate, Print Loop) has been improved: grammar changes are now persistent, and it’s also possible to enter multi-line comments. Some of these changes were backported from the REPL module, as described in this blog post.

The tests for experimental Raku features (such as :pack, :cached, :macros) have been moved from the Raku test-suite (roast) to the Rakudo repository, as they are technically not part of the definition of the Raku Programming Language.

Sadly, the JVM backend has hardly seen any updates the past year. It was therefore decided to not mention the JVM backend in releases anymore, nor to make sure that there would not be any ecosystem breakage on the JVM backend before a release.

If you want the JVM to remain a viable backend, you are very much invited to get involved!

New features in 6.d

The most notable new features in the default language level:

Varargs support in NativeCall

After many years of people asking for this feature, Patrick Böker actually wrote the infrastructure in MoarVM and Rakudo to support calling C-functions that support a variable number of arguments using the va_arg standard.

To give an example, it’s now possible to create a foo subroutine that will call the printf C-function (from the standard library) that takes a format string as the first argument, and a variable number of arguments after that:

use NativeCall;
sub foo(str, **@ --> int32) is native is symbol('printf') {*}
foo "The answer: %d\n", 42;  # The answer: 42

The printf() C-function is a good example of using varargs.

Support for pseudo-terminals (PTY)

Writing terminal applications has become much simpler with the support for pseudo-terminals that Patrick Böker has written. This Advent post explains the how and why of this development, and the new Anolis terminal emulator module.

Support is still a bit raw around the edges: pretty sure the coming year will see a lot of smoothing over, so that it can e.g. be used to create a full featured terminal-based Raku debugger!

Hash.new(a => 42, b => 666)

A common beginner mistake was trying to create a new Hash (or Map) object by using .new and named arguments. This would silently create an empty Hash (or Map) because by default any unexpected named arguments are ignored in calls to .new. This was changed so that if Hash.new (or Map.new) is called with named arguments only, they will be interpreted as key/value pairs to be put into the Hash (or Map):

dd Hash.new(a => 42, b => 666);
# {:a(42), :b(666)}
dd Map.new(a => 42, b => 666);
# Map.new((:a(42),:b(666)))

exit-ok

The Test module now also provides an exit-ok tester subroutine, making it a lot easier to test the exit behaviour of a piece of code. It takes a Callable, and an integer value. It expects the code to execute an exit statement, and will then compare the (implicitly) given exit value with the given integer value.

use Test;
exit-ok { exit 1 }, 1;
# ok 1 - Was the exit code 1?
exit-ok { exit }, 1;
# not ok 2 - Was the exit code 1?
exit-ok { 42 }, 0;
# not ok 3 - Code did not exit, no exit value to check

Language changes (6.e.PREVIEW)

The most notable additions to the future language level of the Raku Programming Language:

Hash::Ordered

An implementation of ordered hashes (a hash in which the order of the keys is determined by order of addition) has become available:

use v6.e.PREVIEW;
my %h is Hash::Ordered = "a".."e" Z=> 1..5;
say %h.keys;    # [a b c d e]
say %h.values;  # (1 2 3 4 5)

This will probably get some easier syntactic sugar. Until then, the above syntax can be used.

Language changes in RakuAST

The following changes are only seen when using RakuAST (by calling raku with the RAKUDO_RAKUAST=1 environment variable set), and thus available by default when the next language level is released.

Setting default language version

The RAKU_LANGUAGE_VERSION environment variable can be used to indicate the default language level with which to compile any Raku source code. Note that this does not affect any explicit language versions specified in the code.

$ RAKUDO_RAKUAST=1 RAKU_LANGUAGE_VERSION=6.e.PREVIEW raku -e 'say nano'
1766430145418821670
$ RAKUDO_RAKUAST=1 RAKU_LANGUAGE_VERSION=6.e.PREVIEW raku -e 'use v6.d; say nano'
===SORRY!=== Error while compiling -e
Undeclared routine:
    nano used at line 1

Although of limited use while RakuAST is not yet the default, it will make it a lot easier to check the behaviour of code at different language levels, e.g. when running tests in the official test-suite (aka roast).

$?SOURCE, $?CHECKSUM

The compile-time variables $?SOURCE and $?CHECKSUM have been added. The $?SOURCE compile-time variable contains the source of the current compilation unit. If for some reason one doesn’t want that to be included in the bytecode, then the RAKUDO_OMIT_SOURCE environment variable can be set.

The $?CHECKSUM compile-time variable contains a SHA1 digest of the source code.

$ RAKUDO_RAKUAST=1 raku -e 'say $?SOURCE'
say $?SOURCE
$ RAKUDO_RAKUAST=1 raku -e 'say $?CHECKSUM'
81892BA38B9BD6930380BD81DB948E4D7A9C14E7
$ RAKUDO_RAKUAST=1 RAKUDO_OMIT_SOURCE=1 raku -e 'say $?SOURCE'
Nil

These additions are intended to be used by the MoarVM runtime debugger, as well as by packagers for verification.

Localization

Most of the localization work has been removed from the Rakudo core and put into separate Raku-L10N project. And there it gained a few new contributors! For a progress report, checkout out habere-et-dipertire‘s advent blog post titled Hallo, Wêreld!

To make it easier to work with code in a specific localization, each localization comes with a “fun” command line script, and an official one. So for instance, the Dutch localization has a “dutku” (for dutch raku) executable (well, actually a CLI script), but also a “kaas” one. Same for French (“freku” and “brie”), etc. The fun one is usually associated with a favourite foodstuff of the language in question.

$ dutku -e 'zeg "foo"'
foo
$ kaas -e 'zeg "foo"'
foo
$ freku -e 'dis "foo"'
foo
$ brie -e 'dis "foo"'
foo

RakuDoc

The RakuDoc v2.0 specification was completed in December 2024, and 2025 was spent implementing it. A compliant renderer is now available by installing the Rakuast::RakuDoc::Render distribution. Work then began on a document management system called Elucid8 which renders the whole Raku documentation (development preview).

From September onwards, Damian Conway and Richard Hainsworth worked on a enumeration system (originally envisioned for RakuDoc v3.0) so that any block – meaning any paragraph, heading, code snippet, formula, etc – can be enumerated simply by prefixing the blocktype with num. It is a far more flexible system than anything encountered in the editor space.

The RakuDoc specification is now at version 2.20.2. The new enumeration specification has not yet been merged to main because work is still being done on getting Rakuast::RakuDoc::Render to implement the new standard.

It really looks like RakuDoc has the potential to becoming the markup language for any type of serious documentation, and a direct competitor to markdown.

Ecosystem

The Raku ecosystem has seen quite a lot of developments. Many modules got moved to the Raku Community Modules Adoption Center where they got a new lease on life. But there were also quite a few new modules, and interesting updates to existing modules in 2025.

Statistics

According to raku.land in 2025, 503 Raku modules have been updated (or first released): up from 367 in 2024 (an increase of 37%). There are now 2431 different modules installable by zef by just mentioning their name. And there are now 13808 different versions of Raku modules available from the Raku Ecosystem Archive, up from 12181 in 2024, which means more than 4.4 module updates / day on average in 2025 (up from 3.9 updates / day).

Interesting new modules

The modules that yours truly found interesting, so a very personal list! In alphabetical order:

Modules with notable updates

Also in alphabetical order:

Bots

A new experimental bot has appeared on the #raku-dev IRC channel: rakkable. It is basically an interactive front end for the new “rakudo-xxx” features of App::Rak. Which in turn is based on the new Ecosystem::Cache module. This allows easy searching in all most current versions of modules in the ecosystem.

For instance: look in the Raku ecosystem for code mentioned in “provides” sections that contain the string “Lock.new” and which also have the string “$!lock”:

<lizmat> rakkable: eco-provides Lock.new --and=$!lock
<rakkable> Running: eco-provides Lock.new --and=$!lock, please be patient!
<rakkable> Found 30 lines in 25 files (24 distributions):
<rakkable> https://gist.github.com/fa2424aebf085ea656b436c63722bf9d

The bot currently only lives on the #raku-dev, but can also be accessed directly without needing the “rakkable:” prefix.

Non-technical stuff

Yes, there’s also non-technical stuff in the Raku world!

Websites

The raku.org website has been completely renewed, thanks to Steve Roe who has taken that on. It’s now completely dogfooded: hypered with htmx. Aloft on Åir. Constructed in cro. Written in raku.  &  Styled by picocss.

Documentation

The Raku Documentation Project has gained quite a few collaborators, who are working on making the Raku documentation more accessible to new users. One factor making this easier, is that the CI testing for the documentation has become about 4x as fast by using RakuAST RakuDoc parsing.

Social Media

Yours truly stopped using what is now X (formerly Twitter). It hurt. But Bluesky and Mastodon are good alternatives, and the people important to yours truly have moved to them. If you haven’t yet, you probably should. As well as the people important to you.

Please be sure to mention the #rakulang tag when posting about the Raku Programming Language!

Conference / Core Summit

Sadly it has turned out to be impossible to organize a Raku Conference (neither in-person or online) this year. Hoping for better times next year! It just really depends on people wanting to put in the effort!

It was possible to organize a second Raku Core Summit in 2025!

Weekly

The Rakudo Weekly News has been brought to you by Steve Roe in the 2nd half of 2025 (and for the foreseeable future). With some new features, such as code gists! Kudos!

Problem Solving

The Problem Solving repository has seen an influx of 36 new issues the past year. They all deserve your attention and your feedback! Some of them specifically ask for your ideas, such as:

Please, don’t be shy and have your voice heard!

Raku Steering Council

Sadly, Vadim Belman and Stefan Seifert have indicated that they wanted to step down from the Raku Steering Council. They are thanked for all that they have done for Raku, the Raku Community in general, and the Raku Steering Council in particular.

John Haltiwanger has accepted an invitation to join the Raku Steering Council. The seat opened by Stefan Seifert will not be filled for at least the coming 6 months.

The Raku Foundation

After writing a blog post about a Raku Foundation, a problem solving issue and many discussions at the second Raku Core Summit, there finally is a version of the Raku Foundation Documents that everybody can agree on (at least for now).

Yours truly urges the readers to check out The Articles Of Association, as these will be very hard to change once the foundation is established.

If you are really interested in this kind of stuff, please check out the Regulations for the operation of the Raku Foundation as well.

And if you would like to become part of the initial Executive Board or the Supervisory Board, please send an email to founding@raku.foundation.

Summary

Looking back, again an amazing amount of work has been done in 2025! And not only on the technical side of things!

Hopefully you will all be able to enjoy the Holiday Season with sufficient R&R. Especially Kane Valentine (aka kawaii) who is still going strong in their new role:

And on that note: Слава Україні!  Героям слава!

The next Raku Advent Blog is only 340 days away!

Day 24 – Maze Making Using Graphs

Introduction

This document (notebook) describes three ways of making mazes (or labyrinths) using graphs. The first two are based on rectangular grids; the third on a hexagonal grid.

All computational graph features discussed here are provided by “Graph”, [AAp1]. The package used for the construction of the third, hexagonal graph is “Math::Nearest”, [AAp2].

TL;DR

Just see the maze pictures below. (And try to solve the mazes.)

Procedure outline

The first maze is made by a simple procedure which is actually some sort of cheating:

  • A regular rectangular grid graph is generated with random weights associated with its edges.
  • The (minimum) spanning tree for that graph is found.
  • That tree is plotted with exaggeratedly large vertices and edges, so the graph plot looks like a maze.
    • This is “the cheat” — the maze walls are not given by the graph.

The second maze is made “properly”:

  • Two interlacing regular rectangular grid graphs are created.
  • The second one has one less row and one less column than the first.
  • The vertex coordinates of the second graph are at the centers of the rectangles of the first graph.
  • The first graph provides the maze walls; the second graph is used to make paths through the maze.
    • In other words, to create a solvable maze.
  • Again, random weights are assigned to edges of the second graph, and a minimum spanning tree is found.
  • There is a convenient formula that allows using the spanning tree edges to remove edges from the first graph.
  • In that way, a proper maze is derived.

The third maze is again made “properly” using the procedure above with two modifications:

  • Two interlacing regular grid graphs are created: one over a hexagonal grid, the other over a triangular grid.
    • The hexagonal grid graph provides the maze walls; the triangular grid graph provides the maze paths.
  • Since the formula for wall removal is hard to derive, a more robust and universal method based on nearest neighbors is used.

Setup

Packages

Here are the packages loaded for use in the rest of the notebook:

use Graph;
use Graph::Classes;

use Math::DistanceFunctions;
use Math::Nearest;

use Data::TypeSystem;
use Data::Translators;
use Data::Generators;

Conversion

This sub is used to invoke the Graphviz graph layout engines:

sub dot-svg($input, Str:D :$engine = 'dot', Str:D :$format = 'svg') {
    my $temp-file = $*TMPDIR.child("temp-graph.dot");
    $temp-file.spurt: $input;
    my $svg-output = run($engine, $temp-file, "-T$format", :out).out.slurp-rest;
    unlink $temp-file;
    return $svg-output;
}


Simple Maze

In this section, we create a simple, “cheating” maze.

Remark: The steps are easy to follow, given the procedure outlined in the introduction.

# Maze dimensions
my ($n, $m) = (10, 25);

# Base grid graph
my $g = Graph::Grid.new($n, $m, :!directed);

# Using the edges of the grid graph make a new graph assigned random edge weights
my $gWeighted = Graph.new($g.edges(:dataset).map({ $_<weight> = random-real([10,1000]); $_}))

# Graph(vertexes => 250, edges => 465, directed => False)

Find the spanning tree of the graph:

my $mazePath = $gWeighted.find-spanning-tree

# Graph(vertexes => 250, edges => 249, directed => False)

Shortest path from the first vertex (bottom-left) to the last vertex (top-right):

my @path = $mazePath.find-shortest-path('0_0', "{$n-1}_{$m-1}");
@path.elems

# 56

Graph plot:

#% html
my $simpleMaze = Graph.new($mazePath.edges);
$simpleMaze.vertex-coordinates = $g.vertex-coordinates;

my %opts =
    background => "Black",
    :!node-labels,
    :!edge-lables,
    node-shape => 'square', 
    node-width => 0.7, 
    node-color => 'SteelBlue',
    node-fill-color => 'SteelBlue',
    edge-thickness => 52, 
    edge-color => 'SteelBlue',
    size => '10,6!',
    engine => 'neato';

$simpleMaze.dot(|%opts):svg

The “maze” above looks like a maze because the vertices and edges are rectangular with matching sizes, and they are thicker than the spaces between them. In other words, we are cheating.

To make that cheating construction clearer, let us plot the shortest path from the bottom left to the top right and color the edges in pink (salmon) and the vertices in red:

#%html
my $gPath = Graph::Path.new(@path);
$simpleMaze.dot(highlight => {Salmon => $gPath.edge-list, Red => $gPath.vertex-list}, |%opts):svg


Proper Maze

A proper maze is a maze given with its walls (not with the space between walls).

Remark: For didactical reasons, the maze in this section is small so that the steps—outlined in the introduction—can be easily followed.

Make two regular graphs: one for the maze walls and the other for the maze paths.

# Maze dimensions
my ($n, $m) = (6, 12) »*» 1;

# Walls graph
my $g1 = Graph::Grid.new($n, $m, prefix => 'w');

# Space graph
my $g2 = Graph::Grid.new($n-1, $m-1);
$g2.vertex-coordinates = $g2.vertex-coordinates.map({ $_.key => $_.value >>+>> 0.5 }).Hash;

$g2

# Graph(vertexes => 55, edges => 94, directed => False)

Maze Path Graph:

my $mazePath = Graph.new($g2.edges(:dataset).map({ $_<weight> = random-real([10,1000]); $_}));
$mazePath = $mazePath.find-spanning-tree;
$mazePath.vertex-coordinates = $g2.vertex-coordinates;

$mazePath

# Graph(vertexes => 55, edges => 54, directed => False)

Combined Graph:

my $g3 = Graph.new([|$g1.edges, |$mazePath.edges]);
$g3.vertex-coordinates = [|$g1.vertex-coordinates, |$mazePath.vertex-coordinates].Hash;

$g3

# Graph(vertexes => 127, edges => 180, directed => False)

Plot the combined graph:

#% html
$g3.dot(
    highlight => $mazePath,
    :node-labels,
    background => "Black",
    node-width => 0.45,
    node-height => 0.2,
    edge-width => 4,
    size => '10,10!',
    engine => 'neato'
):svg

Remove wall edges using a formula:

my $g4 = $g3.clone;
for $mazePath.edges -> $e {

    my ($i, $j) = |$e.key.split('_')».Int;
    my ($i2, $j2) = |$e.value.split('_')».Int;
    
    if $i2 < $i || $j2 < $j { 
        ($i2, $j2, $i, $j) = ($i, $j, $i2, $j2)
    }

    # Horizontal
    if $i == $i2 && $j < $j2 {
        $g4 = $g4.edge-delete( "w{$i2}_{$j2}" => "w{$i2+1}_{$j2}")
    }

    # Vertical
    if $j == $j2 && $i < $i2 {
        $g4 = $g4.edge-delete( "w{$i2}_{$j2}" => "w{$i2}_{$j2+1}")
    }
}

$g4

# Graph(vertexes => 127, edges => 126, directed => False)

Plot wall graph and maze space graph:

#% html
$g4.dot(
    highlight => $mazePath,
    :!node-labels,
    background => "Black",
    node-width => 0.25,
    node-height => 0.2,
    edge-width => 4,
    size => '10,10!',
    engine => 'neato'
):svg

Fancier maze presentation with rectangular vertices and edges (with matching sizes):

#% html
my $g5 = $g4.subgraph($g1.vertex-list);

my @path = $mazePath.find-shortest-path('0_0', "{$n-2}_{$m-2}");
say @path.elems;

my @mazeStartEnd = "w0_0", w0_0 => "w0_1", w0_0 => "w1_0", "w{$n-1}_{$m-1}", "w{$n-1}_{$m-1}" => "w{$n-1}_{$m-2}", "w{$n-1}_{$m-1}" => "w{$n-2}_{$m-1}";

$g4.dot(
    highlight => {'#1F1F1F' => [|$mazePath.vertex-list, |$mazePath.edge-list, |@mazeStartEnd], Orange => @path},
    #highlight => {'#1F1F1F' => @mazeStartEnd},
    background => '#1F1F1F',
    size => '10,10!',
    :!node-labels,
    node-shape => 'square',
    node-color => 'SteelBlue',
    node-fill-color => 'SteelBlue',
    node-width => 0.4,
    edge-width => 30,
    engine => 'neato'
):svg


Hexagonal Version

Let us create another maze based on a hexagonal grid. Here are two grid graphs:

  • The first is a hexagonal grid graph representing the maze’s walls.
  • The second graph is a triangular grid graph with one fewer row and column, and shifted vertex coordinates.
# Maze dimensions
my ($n, $m) = (6, 10) »*» 2;

# Walls graph
my $g1 = Graph::HexagonalGrid.new($n, $m, prefix => 'w');

# Space graph
my $g2 = Graph::TriangularGrid.new($n-1, $m-1);
$g2.vertex-coordinates = $g2.vertex-coordinates.map({ $_.key => $_.value >>+<< [sqrt(3), 1 ] }).Hash;

$g2

Graph(vertexes => 240, edges => 657, directed => False)

#% html
$g1.union($g2).dot(
    highlight => $g2,
    :!node-labels,
    background => "#1F1F1F",
    node-width => 0.85,
    node-height => 0.85,
    node-font-size => 28,
    node-shape => 'hexagon',
    edge-width => 7,
    size => '10,10!',
    engine => 'neato'
):svg

Maze Path Graph:

my $mazePath = Graph.new($g2.edges(:dataset).map({ $_<weight> = random-real([10,1000]); $_}));
$mazePath = $mazePath.find-spanning-tree;
$mazePath = Graph.new($mazePath.edges);
$mazePath.vertex-coordinates = $g2.vertex-coordinates;

$mazePath

# Graph(vertexes => 240, edges => 239, directed => False)

Combine the walls-maze and the maze-path graphs (i.e., make a union of them), and plot the resulting graph:

#% html

my $g3 = $g1.union($mazePath);

$g3.dot(
    highlight => $mazePath,
    :node-labels,
    background => "#1F1F1F",
    node-width => 0.85,
    node-height => 0.85,
    node-font-size => 28,
    node-shape => 'hexagon',
    edge-width => 7,
    size => '10,10!',
    engine => 'neato'
):svg

Make a nearest neighbor points finder functor:

my &finder = nearest($g1.vertex-coordinates.Array, method => 'KDTree');


Math::Nearest::Finder(Algorithm::KDimensionalTree(points => 544, distance-function => &euclidean-distance, labels => 544))

Take a maze edge and its vertex points:

my $e = $mazePath.edges.head;
my @points = $g2.vertex-coordinates{($e.kv)};

# [[-3.4641016151381225 -2] [-1.7320508075691228 1]]

Find the edge’s midpoint and the nearest wall-graph vertices:

my @m = |((@points.head <<+>> @points.tail) >>/>> 2);
say "Mean edge point: {@m}";
my @vs = |&finder.nearest(@m, 2, prop => <label>).flat;
say "To remove: {@vs}";

# Mean edge point: -2.5980762113536224 -0.5
# To remove: w3 w6

Loop over all maze edges, removing wall-maze edges:

my $g4 = $g1.clone;
for $mazePath.edges -> $e {
    my @points = $g2.vertex-coordinates{($e.kv)};
    my @m = |((@points.head <<+>> @points.tail) >>/>> 2);
    my @vs = |&finder.nearest(@m, 2, prop => <label>).flat;
    $g4 = $g4.edge-delete(@vs.head => @vs.tail);
}

$g4

# Graph(vertexes => 544, edges => 544, directed => False)

The start and end points of the maze:

my ($start, $end) = $g4.vertex-list.head, $g4.vertex-list.sort({ $_.substr(1).Int }).tail;

# (w0 w543)

Finding the Maze Solution:

my $solution = Graph::Path.new: $mazePath.find-shortest-path(|$mazePath.vertex-list.sort(*.Int)[0,*-1]);
$solution.vertex-coordinates = $mazePath.vertex-coordinates.grep({$_.key ∈ $solution.vertex-list }).Hash;

$solution

# Graph(vertexes => 50, edges => 49, directed => False)

Plot the maze:

#% html

my @mazeStartEnd = $start, $end, |$g4.neighborhood-graph([$start, $end]).edges;

my $g5 = $g4.union($solution);

my %opts = 
    :!node-labels,
    background => "#1F1F1F",
    node-width => 0.8,
    node-height => 0.8,
    node-shape => 'circle',
    edge-width => 40,
    size => '10,10!',
    engine => 'neato';

$g4.dot(highlight => {'#1F1F1F' => @mazeStartEnd}, |%opts):svg

(Here is the solution of the maze).


Additional Comments

  • The initial (and unfinished) version of this document was created 13 months ago.
    • Its completion was postponed because the blog post “Day 12 – Graphs in Raku”, [AA1], featured many of the graph operations in “Graph”, [AAp1].
      • (Well, until this Raku Advent effort…)
  • The document demonstrates how feature-rich the package “Graph” is.
  • Here are the special graph functionalities used to create the mazes:

References

Articles, Blog Posts

[AA1] Anton Antonov, “Day 12 – Graphs in Raku”, (2024), Raku Advent Calendar at WordPress.

Packages

[AAp1] Anton Antonov, Graph, Raku package, (2024–2025), GitHub/antononcube.

[AAp2] Anton Antonov, Math::Nearest, Raku package, (2024), GitHub/antononcube.

Videos

[AAv1] Anton Antonov, “Graphs” videos playlist, (2024-2025), YouTube/@AAA4prediction.