Part of I. A Diurnal Cipher of Raku.
Yesterday we learned that context dictates how many values flow through an expression. Today, we confront flattening—the metaphysical law deciding whether a nested collection retains its singular, isolated ego or dissolves into the greater collective.
By default, Raku respects the boundaries of form. A list placed inside another list remains stubbornly cloistered within its own dimension:
my @nested = 1, (2, 3), 4;
say @nested;
say "elements: {@nested.elems}";
[1 (2 3) 4]
elements: 3
Observe the horror of the architecture: the middle entity is a single
List occupying a solitary slot. The array counts three top-level
elements, blindly ignoring the inner duality.
The Incantation of the Slip
The prefix | is a cosmic solvent. When applied, it transmutes a rigid
list into a Slip—shattering its outer shell and splicing its inner
components directly into the surrounding context, one level deep.
my @flat = 1, |(2, 3), 4;
say @flat;
say "elements: {@flat.elems}";
[1 2 3 4]
elements: 4
Though the digits on the right remain identical, their structural integrity has collapsed. The array now holds four distinct, liberated elements.
Splicing Existing Realities
The Slip is indispensable when an array already harbor data, and you
wish to merge its contents elsewhere without trapping them in a
recursive prison:
my @middle = 10, 20, 30;
my @row = 0, |@middle, 40;
say @row;
[0 10 20 30 40]
This pattern manifests wherever streams of data converge: when gathering arguments for a grand invocation, building matrices from fractured columns, or synthesizing partial results.
A Glimpse of the Slurpy Maw
This dissolution of form also governs the boundaries of subroutines. A slurpy parameter acts as a localized black hole, absorbing all remaining arguments into a single, cohesive array:
sub total(*@nums) { [+] @nums }
say total(1, 2, 3, 4);
10
While the * prefix on @nums utilizes a different runic syntax, the
underlying philosophy is unchanged: allowing a torrent of individual
entities to expand and fill the available voids.
The Path Ahead
Once your mind accepts the reality-warping nature of |, invocations
like some-func(|@args) and structural unions like [|@left, |@right]
will no longer seem alien. It is the vital connective tissue between
Raku’s structured vessels and the hungry voids that demand raw,
individual values.