## dist_zef-lizmat-Prompt.md
[![Actions Status](https://github.com/lizmat/Prompt/actions/workflows/linux.yml/badge.svg)](https://github.com/lizmat/Prompt/actions) [![Actions Status](https://github.com/lizmat/Prompt/actions/workflows/macos.yml/badge.svg)](https://github.com/lizmat/Prompt/actions) [![Actions Status](https://github.com/lizmat/Prompt/actions/workflows/windows.yml/badge.svg)](https://github.com/lizmat/Prompt/actions)

# NAME

Prompt - a smarter prompt for user interaction

# SYNOPSIS

```
use Prompt;

my $prompt = Prompt.new(:history<here>);
loop {
    last without my $line = $prompt.readline("> ");
    say $line;
}
$prompt.save-history;

```

# DESCRIPTION

The Prompt module offers a better `prompt` experience, drawing on the logic of the Raku REPL.

It also optionally provides a replacement for Raku's standard [`prompt`](https://docs.raku.org/routine/prompt) functionality.

# ROLES

The `Prompt` role is what usually gets punned into a class.

The `Prompt::Fallback` role provides all of the logic if no specific editor has been found. It also serves as a base role for specific editor roles, such as `Prompt::Readline`, `Prompt::LineEditor` and `Prompt::Linenoise`.

## Prompt

The `Prompt` role embodies the information needed to read a line of input from a user, and optionally keep a history of the lines that were entered.

### method new

```
my $Prompt = Prompt.new(
  :editor(Any),    # or "Readline", "LineEditor", "Linenoise"
  :history<here>,                       # default: none
  :completions(@completions),           # default: none
  :additional-completions(&one, &two),  # default: none
);
loop {
    last without my $line = $Prompt.readline;
    say $line;
}
$Prompt.save-history;

```

The `new` method is called to instantiate a `Prompt` object. It takes a number of named arguments described below.

#### :editor

The editor logic to be used. Can be specified as a string, or as an instantiated object that implements the `Prompt::Fallback` role.

If the value is not a string, it is expected to be a class that implements to the `Prompt::Fallback` interface.

Otherwise defaults to `Any`, which means to search first for unknown roles in the `Prompt::` namespace, then to try if there is support installed for [`Readline`](https://raku.land/zef:clarkema/Readline), [`LineEditor`](https://raku.land/zef:japhb/Terminal::LineEditor), or [`Linenoise`](https://raku.land/zef:raku-community-modules/Linenoise).

If that failed, then the `Fallback` editor logic will be used, which may cause a cumbersome user experience, unless the process was wrapped with a call to the [`rlwrap`](https://github.com/hanslub42/rlwrap) readline wrapper.

Used value available with the `.editor` method.

#### :history

String or `IO::Path` object. Specifies the path to keep any lines that have been previously entered and/or will be entered in the future by any user interactions. Defaults to `Any`, indicating **no** history will be kept.

Will load any persistent history already available if the specified path already existed.

Used value available with the `.history` method.

#### :completions

A `List` of strings to be used for tab-completions by the editor. Will only be useful if the `.supports-completions` method returns `True`.

#### :additional-completions

A `List` of `Callables` to be called to support additional completion logic. Will only be useful if the `.supports-completions` method returns `True`.

### method readline

```
my $line = $Prompt.readline("> ");

```

The `readline` method takes a single positional argument for the prompt to be shown (defaults to "> ") and returns a line of input from the user.

The prompt will be scanned for escape sequence [interpolation](#INTERPOLATIONS).

An undefined value is returned if the user has indicated there is no more input to be obtained.

If the `Prompt` object was made with a history file, then that history will be available to the user depending on whether the `editor` used supports that (the `Prompt::Fallback` editor does **not**). And in that case, the `readline` will make sure that any new lines will be added to the history.

Note that to persistently store the history, one **must** call the `save-history`, when appropriate (usually when the user is done).

### method read

```
my $line = $Prompt.read("> ");

```

The `read` method takes a single positional argument for the prompt to be shown and returns a line of input from the user. It does **not** handle anything history related, nor does it do any escape code analysis.

### method completions

```
.say for $Prompt.completions;

$Prompt.completions(<a b c>);

```

The `completions` method returns the current sorted `List` of completions.

If called with a `Positional`, will sort that and use that as the list of completions to use.

### method additional-completions

The `additional-completions` method returns an `Array` of `Callable`s that will be called whenever a completion is requested. Each `Callable` is expected to accepted two positional arguments: the first is the line that has been entered so far by the user, and the second is the position of the cursor when a completion was requested.

### method editor-name

```
say $Prompt.editor-name;

```

The `editor-name` method returns the name of the editor support that was activated. It is intended to be purely informatonal.

### method history

```
my $history = $Prompt.history;

$Prompt.save-history;
$Prompt.history("another-file");

```

Returns the `IO::Path` object representing the persistent history file.

Can also be called with a positional argument, indicating the file to be used for history keeping from now on. Note that if history was already being kept in another history file, any additions to that will be lost unless a call to `save-history` was done before that.

### method add-history

```
$Prompt.add-history($line);

```

The `add-history` method can be called to add a line to the current history. It takes a single positional argument: the line to be added.

Note that calling this method is not needed if the `readline` method is being used to obtain input from a user.

### method load-history

Will (re-)load the history from the file indicated with `history`.

### method save-history

Will save the current history to the file indicated with `history`.

# EDITOR ROLES

An editor role must supply the methods as defined by the `Prompt::Fallback` role. Its `new` method should either return an instantiated class, or `Nil` if the class could not be instantiated (usually because of lack of installed module dependencies).

The other methods are (in alphabetical order):

### add-history

Expected to take a single string argument to be added to the (possibly persistent) history. Does not perform any action by default in `Prompt::Fallback`.

### history

If called as an accessor, should return the `IO::Path` object of the history file.

If called as a mutator with a single positional argument, should set that as the current history file, and load that history.

### load-history

Expected to take no arguments and load any persistent history information, as indicated by its `history` method. Does not perform any action by the default implementation in the `Prompt::Fallback` role.

## read

Expected to take a string argument with the prompt to be shown, and return the next line of input from the user. Expected to return an undefined value to indicate that no further input is to be expected.

Defaults to showing the prompt and taking a line from `$*IN` in `Prompt::Fallback`.

## save-history

Expected to take no arguments and save any persistent history information, as indicated by its `history` method. Does not perform any action by the default implementation in the `Prompt::Fallback` role.

## supports-completions

Expected to take no arguments and return a `Bool` indicating whether this editor supports completions. Defaults to `False` in the `Prompt::Fallback` role.

## Prompt::Fallback

Apart from the definition of the interface for editors, it provides the default logic for handling the interaction with the user.

## Prompt::Readline

The role that implements the user interface using the [`Readline`](https://raku.land/zef:clarkema/Readline) module.

## Prompt::LineEditor

The role that implements the user interface using the [`Terminal::LineEditor`](https://raku.land/zef:japhb/Terminal::LineEditor) module.

## Prompt::Linenoise

The role that implements the user interface using the [`Linenoise`](https://raku.land/zef:raku-community-modules/Linenoise) module.

# SUBROUTINES

## sub prompt

```
use Prompt :prompt;

say prompt("> ");

```

If the `:prompt` named argument is specified with the `use Prompt` statement, a lexical replacement for the standard `prompt` functionality will be exported.

### $\*PROMPT

The `$*PROMPT` dynamic variable will be used to obtain the `Prompt` object to be used in the interaction. If none was found, a new `Prompt` object will be created and stored as `$*PROMPT` in the `PROCESS::` stash (making it automatically available for any subsequent call to the exported `prompt` subroutine).

```
use Prompt :prompt;

my $*PROMPT = Prompt.new(...);
say prompt("> ");

```

If one needs specific initializations with the `Prompt` object, one can also define ones own `$*PROMPT` dynamic variable before calling `prompt`.

# AUTHOR

Elizabeth Mattijsen [liz@raku.rocks](mailto:liz@raku.rocks)

Source can be located at: <https://github.com/lizmat/Prompt> . Comments and Pull Requests are welcome.

If you like this module, or what I'm doing more generally, committing to a [small sponsorship](https://github.com/sponsors/lizmat/) would mean a great deal to me!

# COPYRIGHT AND LICENSE

Copyright 2024, 2025 Elizabeth Mattijsen

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## dist_zef-tbrowder-Date-Christian-Advent.md
[![Actions Status](https://github.com/tbrowder/Date-Christian-Advent/actions/workflows/linux.yml/badge.svg)](https://github.com/tbrowder/Date-Christian-Advent/actions) [![Actions Status](https://github.com/tbrowder/Date-Christian-Advent/actions/workflows/macos.yml/badge.svg)](https://github.com/tbrowder/Date-Christian-Advent/actions) [![Actions Status](https://github.com/tbrowder/Date-Christian-Advent/actions/workflows/windows.yml/badge.svg)](https://github.com/tbrowder/Date-Christian-Advent/actions)

# NAME

Date::Christian::Advent - Provides routines to calculate the date of the First Sunday of Advent in the Christian calendar

# SYNOPSIS

```
use Date::Christian::Advent;
say Advent-Sunday 2021; # OUTPUT: «2021-11-28␤»

```

# DESCRIPTION

Date::Christian::Advent is a module which provides three subroutines to calculate the date of the First Sunday of Advent in the Christian calendar. The three routines are provided so that, eventually, they might be measured for speed to determine the best for use in another module.

The three routines all take a year as their only argument and return a `Date` object:

```
sub Advent-Sunday($year --> Date) is export {...}
sub Advent-Sunday2($year --> Date) is export {...}
sub Advent-Sunday3($year --> Date) is export {...}

```

Method 1: Find the Sunday closest to November 30 (The Feast of St. Andrew), either before or after. If November 30th is a Sunday, then that's First Advent and St. Andrew gets moved. [Source: Malcolm Heath [malcolm@indeterminate.net](mailto:malcolm@indeterminate.net)]

Method 2: Find the Sunday following the last Thursday in November. [Source: Malcolm Heath [malcolm@indeterminate.net](mailto:malcolm@indeterminate.net)]

Method 3: Find the 4th Sunday before Christmas, not counting the Sunday which may be Christmas. Note this is the method attempted by the author of the Perl CPAN module `DateTime::Calendar::Liturgical::Christian`, but it was wrong as noted in the bug report on the CPAN site.

Note: Methods 1 and 2 were suggested by author of the bug report filed with the Perl CPAN module `DateTime::Calendar::Liturgical::Christian` which was partially the inspiration for this module.

# AUTHOR

Tom Browder [tbrowder@acm.org](mailto:tbrowder@acm.org)

# COPYRIGHT AND LICENSE

© 2021-2024 Tom Browder

This library is free software; you may redistribute or modify it under the Artistic License 2.0.


## dist_zef-tony-o-Event-Emitter-Inter-Process.md
# Event::Emitter::Inter-Process

An extension to `Event::Emitter` that will allow you to communicate efficiently between processes.

## Syntax

This module assumes you are familiar with (`Event::Emitter`)[https://github.com/tony-o/perl6-event-emitter]

#### Parent process

```
use Event::Emitter::Inter-Process;

my $event = Event::Emitter::Inter-Process.new;

my Proc::Async $child .=new(:w, 'perl6', '-Ilib', 'child.pl6');

$event.hook($child);

$event.on('echo', -> $data {
  # got $data from child;
  say $data.decode;
});

$child.start;
sleep 1;

$event.emit('echo'.encode, 'hello'.encode);
$event.emit('echo'.encode, 'world'.encode);

sleep 2;

```

#### Child process

```
use Event::Emitter::Inter-Process;

my $event = Event::Emitter::Inter-Process.new(:sub-process);

$event.on('echo', -> $data {
  "child echo: {$data.decode}".say;
  $event.emit('echo'.encode, $data);
});

sleep 3;

```

##### Parent output:

```
hello
world

```

##### Child output:

```
child echo: hello
child echo: world

```

# License

Free for all.


## append.md
append

Combined from primary sources listed below.

# [In Independent routines](#___top "go to top of document")[§](#(Independent_routines)_sub_append "direct link")

See primary documentation
[in context](/type/independent-routines#sub_append)
for **sub append**.

```raku
multi append(\a, **@b is raw)
multi append(\a, \b)
```

Calls method `append` on the first argument, passing the remaining arguments. Method `append` is supposed to add the provided values to the end of the collection or parts thereof. Unlike method `push`, method `append` should follow the [single argument rule](/language/functions#Slurpy_conventions). So if you want to implement a conforming method `append` for a new collection type, it should behave as if its signature was just:

```raku
multi method append(::?CLASS:D: +values --> ::?CLASS:D)
```

Similar to [routine `push`](/routine/push#(Independent_routines)_sub_push), you may need to add a multi method if you want to support autovivification:

```raku
multi method append(::?CLASS:U: +values --> ::?CLASS:D)
```

The subroutine form of `append` can be helpful when appending to the values of a [`Hash`](/type/Hash). Whereas [method `append`](/routine/append#(Hash)_method_append) will silently ignore literal pairs that are interpreted as named arguments, the subroutine will throw:

```raku
my %h = i => 0;
append %h, i => (1, 42);
CATCH { default { put .message } };
# OUTPUT: «Unexpected named argument 'i' passed␤»
```

# [In Any](#___top "go to top of document")[§](#(Any)_method_append "direct link")

See primary documentation
[in context](/type/Any#method_append)
for **method append**.

```raku
multi method append(Any:U \SELF: |values)
```

In the case the instance is not a positional-thing, it instantiates it as a new [`Array`](/type/Array), otherwise clone the current instance. After that, it appends the values passed as arguments to the array obtained calling [`Array.append`](/type/Array#method_append) on it.

```raku
my $a;
say $a.append; # OUTPUT: «[]␤»
my $b;
say $b.append((1,2,3)); # OUTPUT: «[1 2 3]␤»
```

# [In Array](#___top "go to top of document")[§](#(Array)_method_append "direct link")

See primary documentation
[in context](/type/Array#method_append)
for **method append**.

```raku
multi method append(Array:D: **@values is raw --> Array:D)
multi method append(Array:D: \arg --> Array:D)
```

Adds the provided values to the end of the array and returns the modified array, or throws if the invocant array or an argument that requires flattening [is lazy](/routine/is-lazy).

In contrast with [method push](/type/Array#method_push), method `append` adheres to the [single argument rule](/language/functions#Slurpy_conventions) and is probably best thought of as:

```raku
multi method append(Array:D: +values --> Array:D)
```

This means that if you pass a **single** argument that is a non-[itemized](/language/mop#VAR) [`Iterable`](/type/Iterable), `append` will try to flatten it.

For example:

```raku
my @a = <a b c>;
my @b = <d e f>;
@a.append: @b;
say @a.elems;               # OUTPUT: «6␤»
say @a;                     # OUTPUT: «[a b c d e f]␤»
```

# [In role Buf](#___top "go to top of document")[§](#(role_Buf)_method_append "direct link")

See primary documentation
[in context](/type/Buf#method_append)
for **method append**.

```raku
method append( $elems )
```

Appends to the end of the buffer.

```raku
my $bú = Buf.new( 1, 1, 2, 3, 5 );
$bú.append(9, 8, 7, 6);
say $bú.raku; # OUTPUT: «Buf.new(1,1,2,3,5,9,8,7,6)␤»
```

# [In Hash](#___top "go to top of document")[§](#(Hash)_method_append "direct link")

See primary documentation
[in context](/type/Hash#method_append)
for **method append**.

```raku
method append(+@values)
```

Append the provided Pairs or even sized list to the Hash. If a key already exists, turn the existing value into an [`Array`](/type/Array) and push new value onto that [`Array`](/type/Array). Please note that you can't mix even sized lists and lists of Pairs. Also, bare [`Pair`](/type/Pair)s or colon pairs will be treated as [named arguments](/language/signatures#Positional_vs._named_arguments) to `.append`.

```raku
my %h = a => 1;
%h.append('b', 2, 'c', 3);
%h.append( %(d => 4) );
say %h;
# OUTPUT: «{a => 1, b => 2, c => 3, d => 4}␤»
%h.append('a', 2);
# OUTPUT: «{a => [1 2], b => 2, c => 3, d => 4}␤»
```

**Note:** Compared to [`push`](/routine/push), `append` will [`slip`](/routine/slip) in the given value, whereas `push` will add it as is:

```raku
my %hb = :a[42, ]; %hb.append: "a" => <a b c a>;
say %hb; # OUTPUT: «{a => [42 a b c a]}␤»

my %ha = :a[42, ]; %ha.push: "a" => <a b c a>;
say %ha; # OUTPUT: «{a => [42 (a b c a)]}␤»
```

# [In IterationBuffer](#___top "go to top of document")[§](#(IterationBuffer)_method_append "direct link")

See primary documentation
[in context](/type/IterationBuffer#method_append)
for **method append**.

```raku
method append(IterationBuffer:D: IterationBuffer:D $other --> IterationBuffer:D)
```

Adds the contents of the other `IterationBuffer` at the end of the `IterationBuffer`, and returns the updated invocant.

# [In Nil](#___top "go to top of document")[§](#(Nil)_method_append "direct link")

See primary documentation
[in context](/type/Nil#method_append)
for **method append**.

```raku
method append(*@)
```

Warns the user that they tried to append onto a `Nil` (or derived type object).


## dist_zef-lizmat-Trap.md
[![Actions Status](https://github.com/lizmat/Trap/actions/workflows/linux.yml/badge.svg)](https://github.com/lizmat/Trap/actions) [![Actions Status](https://github.com/lizmat/Trap/actions/workflows/macos.yml/badge.svg)](https://github.com/lizmat/Trap/actions) [![Actions Status](https://github.com/lizmat/Trap/actions/workflows/windows.yml/badge.svg)](https://github.com/lizmat/Trap/actions)

# NAME

Trap - Trap $\*OUT and/or $\*ERR output

# SYNOPSIS

```
use Trap;

my $out;
my $err;
{   # separate capturing
    $out = Trap(my $*OUT);
    $err = Trap(my $*ERR);
    say "Hello world!";
    note "Goodbye!"
}
print "STDOUT: $out.text()";  # SDDOUT: Hello world!␤
print "STDERR: $err.text()";  # STDERR: Goodbye!␤

my $merged;
{   # merged capturing
    $merged = Trap(my $*OUT, my $*ERR);
    say "Hello world!";
    note "Goodbye!"
}
print $merged.text;  # Hello world!␤Goodbye!␤

my $new;
{   # creating the object manually
    $new = my $*OUT = Trap.new;
    say "Hello world!";
}
print "with object: $new.text()";  # with object: Hello world!␤

{   # ignoring any output
    Trap(my $*OUT, my $*ERR);
    say "shall never be seen";
}

```

# DESCRIPTION

Trap exports a class `Trap` that can be called to capture standard output and/or standard error, typically for a lexical scope.

The class can be called with either one or two arguments, each of which should be a writeable local dynamic variable `$*OUT` or `$*OUT`. Or one can create the `Trap` object manually. Or one can use `Trap` to just trap the standard output and/or standard error (see SYNOPSIS for examples).

Note that if you're only interested in surpressing output from **warnings**, you should use the `quietly` statement prefix.

# AUTHOR

Elizabeth Mattijsen [liz@raku.rocks](mailto:liz@raku.rocks)

Source can be located at: <https://github.com/lizmat/Trap> . Comments and Pull Requests are welcome.

If you like this module, or what I’m doing more generally, committing to a [small sponsorship](https://github.com/sponsors/lizmat/) would mean a great deal to me!

# COPYRIGHT AND LICENSE

Copyright 2022, 2024 Elizabeth Mattijsen

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## dist_github-nige123-Do123.md
# app.123.do

123 - a timeline to help your work flow: do, doing, done

To install:

[Install Perl 6](http://perl6intro.com/#_installing_perl_6)

shell> zef install Do123

shell> 123 help

![](images/demo.gif?raw=true)


## dist_zef-antononcube-Math-NumberTheory.md
# Math::NumberTheory

Raku package with Number theory functions.

The function names and features follow the
[Number theory functions of Wolfram Language](http://reference.wolfram.com/language/guide/NumberTheory.html).

**Remark:** Raku has some nice built-in Number theory functions, like, `base`, `gcd`, `mod`, `polymod`, `expmod`, `is-prime`.
They somewhat lack generality, hence their functionalities are extended with this package.
For example, `is-prime` works with lists and [Gaussian integers](https://en.wikipedia.org/wiki/Gaussian_integer).

---

## Installation

From [Zef ecosystem](https://raku.land):

```
zef install Math::NumberTheory

```

From GitHub:

```
zef install https://github.com/antononcube/Raku-Math-NumberTheory

```

---

## Usage examples

## GCD

The infix operator `gcd` for calculating the Greatest Common Divisor (GCD)
is extended to work with rational numbers and [Gaussian integers](https://en.wikipedia.org/wiki/Gaussian_integer):

### Rationals

For rational numbers `r1` and `r2`, `r1 gcd r2` gives the greatest rational number `r` for which `r1/r` and `r2/r` are integers.

```
use Math::NumberTheory;
<1/3> gcd <2/5> gcd <1/7>
==> {.raku}()

```

```
# <1/105>

```

### Gaussian integers

GCD for two Gaussian integers (complex numbers with integer real and imaginary parts):

```
(10 + 15i) gcd (-3 + 2i)

```

```
# -3+2i

```

```
105 gcd (7 + 49i)

```

```
# 7+14i

```

Here is verification of the latter:

```
say 105 / (7 + 14i);
say (7 + 49i) / (7 + 14i);

```

```
# 3-6i
# 3+1i

```

### Prime number testing

The built-in sub `is-prime` is extended to work with [Gaussian integers](https://en.wikipedia.org/wiki/Gaussian_integer):

```
say is-prime(2 + 1i);
say is-prime(5, :gaussian-integers);

```

```
# True
# False

```

Another extension is threading over lists of numbers:

```
is-prime(^6)

```

```
# (False False True True False True)

```

### Factor integers

Gives a list of the prime factors of an integer argument, together with their exponents:

```
factor-integer(factorial(20))

```

```
# [(2 18) (3 8) (5 4) (7 2) (11 1) (13 1) (17 1) (19 1)]

```

**Remark:** By default `factor-integer` uses [Pollard's Rho algorithm](https://en.wikipedia.org/wiki/Pollard's_rho_algorithm) --
specified with `method => 'rho'` --
as implemented at RosettaCode, [RC1], with similar implementations provided by "Prime::Factor", [SSp1], and "Math::Sequences", [RCp1].

Do partial factorization, pulling out at most `k` distinct factors:

```
factor-integer(factorial(20), 3, method => 'trial')

```

```
# [(2 18) (3 8) (5 4)]

```

### Chinese remainders

Data:

```
my @data = 931074546, 117172357, 482333642, 199386034, 394354985;

```

```
# [931074546 117172357 482333642 199386034 394354985]

```

Keys:

```
#my @keys = random-prime(10**9 .. 10**12, @data.elems);
my @keys = 274199185649, 786765306443, 970592805341, 293623796783, 238475031661;

```

```
# [274199185649 786765306443 970592805341 293623796783 238475031661]

```

**Remark:** Using these larger keys is also a performance check.

Encrypted data:

```
my $encrypted = chinese-remainder(@data, @keys);

```

```
# 6681669841357504673192908619871066558177944924838942629020

```

Decrypted:

```
my @decrypted = @keys.map($encrypted mod *);

```

```
# [931074546 117172357 482333642 199386034 394354985]

```

### Modular exponentiation and modular inversion

The sub `power-mod` extends the built-in sub `expmod`.
The sub `modular-inverse` is based on `power-mod`.

`expmod` gives an error and no result when the 1st argument cannot be inverted with the last argument:

```
expmod(30, -1, 12)

```

```
#ERROR: Error in mp_exptmod: Value out of range
# Nil

```

`power-mod` returns `Nil`:

```
power-mod(30, -1, 12).defined

```

```
# False

```

### Number-base related

There are several subs that provide functionalities related to number systems representation.

For example, here we find the digit-breakdown of $100!$:

```
100.&factorial.&digit-count

```

```
# {0 => 30, 1 => 15, 2 => 19, 3 => 10, 4 => 10, 5 => 14, 6 => 19, 7 => 7, 8 => 14, 9 => 20}

```

Here is an example of using `real-digits`:

```
real-digits(123.55555)

```

```
# ([1 2 3 5 5 5 5 5] 3)

```

Non-integer bases can be also used:

```
my $r = real-digits(π, ϕ);

```

```
# ([1 0 0 0 1 0 0 1 0 1 0 1 0 0 1 0 0 0 1 0 1 0 1 0 1 0 0 0 0 0 1 0 1 0 0 1 0 0 0 0 1 0 0 1 0 1 0 0 0 1 0 0 0 0 0 1 0 1 0 1 0 1] 3)

```

Here we recover $\pi$ from the Golden ratio representation obtained above:

```
$r.head.kv.map( -> $i, $d { $d * ϕ ** ($r.tail - $i - 1)  }).sum.round(10e-12);

```

```
# 3.1415926535899996

```

The sub `phi-number-system` can be used to compute
[Phi number system](https://mathworld.wolfram.com/PhiNumberSystem.html)
representations:

```
.say for (^7)».&phi-number-system

```

```
# ()
# (0)
# (1 -2)
# (2 -2)
# (2 0 -2)
# (3 -1 -4)
# (3 1 -4)

```

**Remark:** Because of the approximation of the Golden ratio used in “Math::NumberTheory”,
in order to get exact integers from phi-digits we have to round using small multiples of 10.

---

## TODO

* TODO Implementation
  * DONE Gaussian integers GCD
  * DONE Gaussian integers factorization
  * DONE Moebius Mu function, Liouville lambda function
    * DONE Integers
    * DONE Gaussian integers
  * DONE Square-free test
    * DONE Integers
    * DONE Gaussian integers
  * DONE Rational numbers GCD
  * DONE Multiplicative Order
  * DONE Gaussian integers LCM
  * DONE Rational numbers LCM
  * DONE Carmichael lambda
  * TODO Integer partitions
  * TODO Sum of squares representation
  * TODO Figure out which memoization approach to use:
    * Via the package ["Memoize"](https://raku.land/zef:lizmat/Memoize)
    * Via `use experimental :cached` and `sub blah(...) is cached {...}`
  * TODO CLI
* TODO Documentation
  * TODO Blog post on first non-zero digit of 10\_000!
  * TODO Videos
    * DONE [Neat examples 1](https://www.youtube.com/watch?v=wXXWyRAAPvc)
    * DONE [Neat examples 2](https://www.youtube.com/watch?v=6uCIoonlybk)
    * DONE [Neat examples 3](https://www.youtube.com/watch?v=6uCIoonlybk)
      * See also the related posts [AA1, AAn4].
    * TODO Neat examples 4
    * TODO Neat examples 5

---

## References

### Articles, blog posts, wiki-pages

[AA1] Anton Antonov,
["Primitive roots generation trails"](https://mathematicaforprediction.wordpress.com/2025/04/08/primitive-roots-generation-trails/),
(2025),
[MathematicaForPrediction at WordPress](https://mathematicaforprediction.wordpress.com).

[RC1] Rosetta Code, [Prime decomposition](https://rosettacode.org/wiki/Prime_decomposition),
[Section "Pure Raku"](https://rosettacode.org/wiki/Prime_decomposition#Pure_Raku).

### Notebooks

[AAn1] Anton Antonov,
[Number theory neat examples Set 1](https://github.com/antononcube/RakuForPrediction-blog/blob/main/Presentations/Notebooks/Number-theory-neat-examples-Set-1.ipynb),
[*presentation notebook*](https://www.youtube.com/watch?v=wXXWyRAAPvc),
(2025),
[RakuForPrediction-blog at GitHub](https://github.com/antononcube/RakuForPrediction-blog).

[AAn2] Anton Antonov,
[Number theory neat examples Set 2](https://github.com/antononcube/RakuForPrediction-blog/blob/main/Presentations/Notebooks/Number-theory-neat-examples-Set-2.ipynb),
[*presentation notebook*](https://www.youtube.com/watch?v=sMwuGVvkLkU),
(2025),
[RakuForPrediction-blog at GitHub](https://github.com/antononcube/RakuForPrediction-blog).

[AAn3] Anton Antonov,
[Number theory neat examples Set 3](https://github.com/antononcube/RakuForPrediction-blog/blob/main/Presentations/Notebooks/Number-theory-neat-examples-Set-3.ipynb),
[*presentation notebook*](https://www.youtube.com/watch?v=6uCIoonlybk),
(2025),
[RakuForPrediction-blog at GitHub](https://github.com/antononcube/RakuForPrediction-blog).

[AAn4] Anton Antonov,
["Primitive roots generation trails"](https://community.wolfram.com/groups/-/m/t/3442027),
(2025),
[Wolfram Community](https://community.wolfram.com).

### Packages

[RCp1] Raku Community,
[Math::Sequences Raku package](https://github.com/raku-community-modules/Math-Sequences),
(2016-2024),
[GitHub/raku-community-modules](https://github.com/raku-community-modules).

[SSp1] Stephen Schulze,
[Prime::Factor Raku package](https://github.com/thundergnat/Prime-Factor),
(2016-2023),
[GitHub/thundergnat](https://github.com/thundergnat).

### Videos

[AAv1] Anton Antonov,
["Number theory neat examples in Raku (Set 1)"](https://www.youtube.com/watch?v=wXXWyRAAPvc),
(2025),
[YouTube/@AAA4prediction](https://www.youtube.com/@AAA4prediction).

[AAv2] Anton Antonov,
["Number theory neat examples in Raku (Set 2)"](https://www.youtube.com/watch?v=sMwuGVvkLkU),
(2025),
[YouTube/@AAA4prediction](https://www.youtube.com/@AAA4prediction).

[AAv3] Anton Antonov,
["Number theory neat examples in Raku (Set 3)"](https://www.youtube.com/watch?v=6uCIoonlybk),
(2025),
[YouTube/@AAA4prediction](https://www.youtube.com/@AAA4prediction).


## roll.md
roll

Combined from primary sources listed below.

# [In List](#___top "go to top of document")[§](#(List)_routine_roll "direct link")

See primary documentation
[in context](/type/List#routine_roll)
for **routine roll**.

```raku
multi        roll($count, *@list --> Seq:D)
multi method roll(List:D: $count --> Seq:D)
multi method roll(List:D: --> Mu)
```

If `$count` is supplied: Returns a sequence of `$count` elements, each randomly selected from the list. Each random choice is made independently, like a separate die roll where each die face is a list element. If `*` is passed as `$count` returns a lazy, infinite sequence of randomly chosen elements from the original list.

If `$count` is omitted: Returns a single random item from the list, or Nil if the list is empty

Examples:

```raku
say <a b c d e>.roll;       # 1 random letter
say <a b c d e>.roll: 3;    # 3 random letters
say roll 8, <a b c d e>;    # 8 random letters

my $random-digits := (^10).roll(*);
say $random-digits[^15];    # 15 random digits
```

# [In role Baggy](#___top "go to top of document")[§](#(role_Baggy)_method_roll "direct link")

See primary documentation
[in context](/type/Baggy#method_roll)
for **method roll**.

```raku
multi method roll(Baggy:D: --> Any:D)
multi method roll(Baggy:D: $count --> Seq:D)
```

Like an ordinary list [roll](/type/List#routine_roll), but returns keys of the invocant weighted by their values, as if the keys were replicated the number of times indicated by the corresponding value and then list roll used. The underlying metaphor for rolling is that you're throwing `$count` dice that are independent of each other, which (in bag terms) is equivalent to picking a colored marble out your bag and then putting it back, and doing this `$count` times. In dice terms, the number of marbles corresponds to the number of sides, and the number of marbles of the same color corresponds to the number of sides with the same color. (For "picking without replacement" see [pick](#method_pick) instead).

If `*` is passed to `$count`, returns a lazy, infinite sequence of randomly chosen elements from the invocant.

```raku
my $breakfast = bag <eggs bacon bacon bacon>;
say $breakfast.roll;                                  # OUTPUT: «bacon␤»
say $breakfast.roll(3);                               # OUTPUT: «(bacon eggs bacon)␤»

my $random_dishes := $breakfast.roll(*);
say $random_dishes[^5];                               # OUTPUT: «(bacon eggs bacon bacon bacon)␤»
```

# [In enum Bool](#___top "go to top of document")[§](#(enum_Bool)_routine_roll "direct link")

See primary documentation
[in context](/type/Bool#routine_roll)
for **routine roll**.

```raku
multi method roll(Bool:U --> Bool:D)
multi method roll(Bool:U $count --> Seq:D)
```

Returns `True` or `False` if called without any argument. Otherwise returns `$count` elements chosen at random. Note that each random choice from the `enum` is made independently, like a separate coin toss where each side of the coin represents one of the two values of the `enum`. If `*` is passed as `$count` an infinite [`Seq`](/type/Seq) of `Bool`s is returned.

```raku
say Bool.roll;                                    # OUTPUT: «True␤»
say Bool.roll(3);                                 # OUTPUT: «(True False False)␤»
say Bool.roll(*);                                 # OUTPUT: «(...)␤»
```

# [In role Enumeration](#___top "go to top of document")[§](#(role_Enumeration)_method_roll "direct link")

See primary documentation
[in context](/type/Enumeration#method_roll)
for **method roll**.

```raku
multi method roll(::?CLASS:U:)
multi method roll(::?CLASS:U: \n)
multi method roll(::?CLASS:D: *@pos)
```

They work on the defined class selecting one or `n` elements without eliminating them.

```raku
say Norse-gods.roll() for ^3;  # OUTPUT: «Freija␤Freija␤Oðin␤»

```

# [In Range](#___top "go to top of document")[§](#(Range)_method_roll "direct link")

See primary documentation
[in context](/type/Range#method_roll)
for **method roll**.

```raku
multi method roll(Range:D:         --> Any:D)
multi method roll(Range:D: $number --> Seq:D)
```

Performs the same function as `Range.list.roll`, but attempts to optimize by not actually generating the list if it is not necessary.

# [In Any](#___top "go to top of document")[§](#(Any)_method_roll "direct link")

See primary documentation
[in context](/type/Any#method_roll)
for **method roll**.

```raku
multi method roll(--> Any)
multi method roll($n --> Seq)
```

Coerces the invocant to a `list` by applying its [`.list`](/routine/list) method and uses [`List.roll`](/type/List#routine_roll) on it.

```raku
my Mix $m = ("þ" xx 3, "ð" xx 4, "ß" xx 5).Mix;
say $m.roll;    # OUTPUT: «ð␤»
say $m.roll(5); # OUTPUT: «(ß ß þ ß þ)␤»
```

`$m`, in this case, is converted into a list and then a (weighted in this case) dice is rolled on it. See also [`List.roll`](/type/List#routine_roll) for more information.

# [In role Setty](#___top "go to top of document")[§](#(role_Setty)_method_roll "direct link")

See primary documentation
[in context](/type/Setty#method_roll)
for **method roll**.

```raku
multi method roll($count = 1)
```

Returns a lazy list of `$count` elements, each randomly selected from the set. Each random choice is made independently, like a separate die roll where each die face is a set element.

If `*` is passed as `$count`, the list is infinite.

# [In role Mixy](#___top "go to top of document")[§](#(role_Mixy)_method_roll "direct link")

See primary documentation
[in context](/type/Mixy#method_roll)
for **method roll**.

```raku
method roll($count = 1)
```

Similar to a [`Bag`](/type/Bag).roll, but with [`Real`](/type/Real) weights rather than integral ones.


## dist_cpan-CTILMES-GraphQL-Server.md
# Perl 6 GraphQL Server

Broke this out of the main GraphQL module. I'm not really using
it anymore, having switched from Bailador to Cro.

I'll add tests and documentation at some point..

Copyright © 2017 United States Government as represented by the
Administrator of the National Aeronautics and Space Administration.
No copyright is claimed in the United States under Title 17,
U.S.Code. All Other Rights Reserved.


## dist_zef-rawleyfowler-Monad-Result.md
# Monad-Result

[![SparrowCI](https://ci.sparrowhub.io/project/gh-rawleyfowler-Monad-Result/badge?)](https://ci.sparrowhub.io)

An implementation of the result monad from OCaml. This allows the developer to completely avoid exceptions.
Note the result type is not generic, and cannot be statically typed. I think this makes it more flexible overall,
compared to OCaml's result monad. (Gradual typing ftw)!

## How to use (default)

```
use Monad::Result;

sub my-error-causing-function($value --> Result) {
  return Monad::Result.error('Bad value!') if $value eq 'bad'
  ok('Value was good!');
}

# Bind operator: >>=:
my-error-causing-function('bad') >>=: -> $value {
  say $value; # Is not called because this is not bindable (it is an error!)
  return Monad::Result.ok($value);
};

my-error-causing-function('abc') >>=: -> $value {
  say $value; # Is said because this is bindable, it is OK!
  return Monad::Result.ok($value);
};

# Map operator: >>=?
# Since this call results in OK, we can map it!
my $result = (my-error-causing-function('abc') >>=? -> $value {
  $value ~ ' HELLO WORLD';
}); # Results Ok('abc HELLO WORLD');

say $result.is-ok; # True
# NOTE UNWRAP IS DANGEROUS (In this case we know it's okay though!)
say $result.unwrap; # 'abc HELLO WORLD';

```

## How to use (subs)

Subs exist as a separate import, because they interfere with a lot of common packages.

```
use Monad::Result :subs;

sub my-error-causing-function($value --> Result) {
  return error('Bad value!') if $value eq 'bad'
  ok('Value was good!');
}

# Bind operator: >>=:
my-error-causing-function('bad') >>=: -> $value {
  say $value; # Is not called because this is not bindable (it is an error!)
  return ok($value);
};

my-error-causing-function('abc') >>=: -> $value {
  say $value; # Is said because this is bindable, it is OK!
  return ok($value);
};

# Map operator: >>=?
# Since this call results in OK, we can map it!
my $result = (my-error-causing-function('abc') >>=? -> $value {
  $value ~ ' HELLO WORLD';
}); # Results Ok('abc HELLO WORLD');

say $result.is-ok; # True
# NOTE UNWRAP IS DANGEROUS!
say $result.unwrap; # 'abc HELLO WORLD';

```

## How to install

```
zef install Monad-Result

```

## LICENSE

Monad::Result is provided under the Artistic-2.0 license.


## any.md
any

Combined from primary sources listed below.

# [In Any](#___top "go to top of document")[§](#(Any)_method_any "direct link")

See primary documentation
[in context](/type/Any#method_any)
for **method any**.

```raku
method any(--> Junction:D)
```

Interprets the invocant as a list and creates an [any](/routine/any)-[`Junction`](/type/Junction) from it.

```raku
say so 2 == <1 2 3>.any;        # OUTPUT: «True␤»
say so 5 == <1 2 3>.any;        # OUTPUT: «False␤»
```


## nfd.md
class NFD

Codepoint string in Normal Form D (decomposed)

```raku
class NFD is Uni {}
```

A Codepoint string in the "D" [Unicode Normalization Form](https://www.unicode.org/reports/tr15/)

# [Typegraph](# "go to top of document")[§](#typegraphrelations "direct link")

Type relations for `NFD`

raku-type-graph

NFD
NFD

Uni
Uni

NFD->Uni

Mu
Mu

Any
Any

Any->Mu

Positional
Positional

Stringy
Stringy

Uni->Any

Uni->Positional

Uni->Stringy

[Expand chart above](/assets/typegraphs/NFD.svg)


## dist_zef-lizmat-WriteOnceHash.md
[![Actions Status](https://github.com/lizmat/WriteOnceHash/actions/workflows/linux.yml/badge.svg)](https://github.com/lizmat/WriteOnceHash/actions) [![Actions Status](https://github.com/lizmat/WriteOnceHash/actions/workflows/macos.yml/badge.svg)](https://github.com/lizmat/WriteOnceHash/actions) [![Actions Status](https://github.com/lizmat/WriteOnceHash/actions/workflows/windows.yml/badge.svg)](https://github.com/lizmat/WriteOnceHash/actions)

# NAME

WriteOnceHash - be a Hash in which each key can only be set once

# SYNOPSIS

```
use WriteOnceHash;

# bind to predefined class
my %woh is WriteOnceHash;
%woh<a> = 5; # ok
%woh<a> = 1; # throws

CATCH {
    when X::Hash::WriteOnce {
        say "Sorry, already set {.key} before";
        .resume
    }
}

# mix in role on anything that does Associative
my %owoh{Any} does WriteOnce;

```

# DESCRIPTION

This module makes an `WriteOnceHash` class available that can be used instead of the normal `Hash`. The only difference with a normal `Hash` is, is that if an attempt is made to set the value of a key that **has already been set before**, an exception is thrown rather than just overwriting the key in the `Hash`.

Also binding to non-existing keys in the hash, and then assigning to the obtained container, will only work once. Iterating over values of the hash will only yield values, not containers (as a normal `Hash` would).

Also exports a `X::Hash::WriteOnce` error class that will be thrown if an attempt is made to set a key again.

The underlying `WriteOnce` role is also exported that can be used on objects that perform the `Associative` role that are not `Hash` (such as object hashes).

# AUTHOR

Elizabeth Mattijsen [liz@raku.rocks](mailto:liz@raku.rocks)

Source can be located at: <https://github.com/lizmat/WriteOnceHash> . Comments and Pull Requests are welcome.

If you like this module, or what I’m doing more generally, committing to a [small sponsorship](https://github.com/sponsors/lizmat/) would mean a great deal to me!

# COPYRIGHT AND LICENSE

Copyright 2018, 2020, 2021, 2024, 2025 Elizabeth Mattijsen

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## dist_github-jsimonet-DNS-Zone.md
[![Build Status](https://travis-ci.org/jsimonet/dns-zone.svg?branch=master)](https://travis-ci.org/jsimonet/dns-zone)

# What

A tool providing an easy way to manage a DNS file zone.

# Why

For fun, because similar modules already exists in Perl 5.
I wanted to use Perl 6 to discover the language, and to learn with a concrete
project.

# How

## Grammar

The main part of this project is to write a grammar for parsing a DNS zone file.
As a result, we will obtain an AST "DNSZone" object, representing the content of this
file.

## AST

This object will contains methods to add, update and remove an entry.

The last step is to write a new zone file based on the new AST.


## dist_cpan-JACKMILES-Hyperscript.md
# hyperscript

Create hypertext with Raku.

## api

```
sub hyperscript(Str $tag, *%attrs, *@inner)

```

* `Str $tag`:
  * The HTML tag to be created.
  * Supports class and id shortcuts, e.g.: `'p#id.class'`.
  * if `$tag` begins with a class or id shortcut, hyperscript uses a `div` element.
* `*%attrs`: HTML attributes on the element.
* `*@inner`: Inner contents for the element.

## example

```
use Hyperscript;
constant &h = &hyperscript;

say h('h1', 'hello, world!');
# OUTPUT: <h1>hello, world!</h1>

```

## slightly longer example

```
use Hyperscript;
constant &h = &hyperscript;

my $html =
h('div#page',
  h('div#header',
    h('h1.classy', style => { background-color => '#22f'}, 'h')),
  h('div#menu', style => { background-color => '#2f2' },
    h('ul',
      h('li', 'one'),
      h('li', 'two'),
      h('li', 'three'))),
  h('h2', style => { background-color => '#f22' }, 'content title'),
  h('p',
    "so it's just like a templating engine, ",
    "but easy to use inline with Raku"),
  h('p',
    "the intention is for this to be used to create ",
    "reusable, interactive html widgets."));

```

## 'pretty' output

By default, hyperscript outputs a condensed string of HTML. Sometimes it may be useful to have
a string representation that more closely reflects the nesting structure of your HTML. 'Pretty' output
can be enabled when needed by setting the `$*hyperscript-style` dynamic variable.

Running this Raku code:

```
use Hyperscript;
my &h = &hyperscript;

my @items = do for 1..3 {
  h('li.condensed', h('a.condensed', :href("page$_.html"), h('b.condensed', "Page $_")))
}

my $site-nav = do {
  my $*hyperscript-style = Hyperscript::Style::Pretty; # Enable pretty output
  h('nav.pretty', h('ul.pretty', @items))
}

say $site-nav;

```

Will provide the following HTML:

```
<nav class="pretty">
  <ul class="pretty">
    <li class="condensed"><a class="condensed" href="page1.html"><b class="condensed">Page 1</b></a></li>
    <li class="condensed"><a class="condensed" href="page2.html"><b class="condensed">Page 2</b></a></li>
    <li class="condensed"><a class="condensed" href="page3.html"><b class="condensed">Page 3</b></a></li>
  </ul>
</nav>

```

## why?

* It produces HTML from Raku code, instead of a separate templating language.
* It's a way to learn Raku module development.

## prior art

* Hyperscript (JavaScript library): <https://github.com/hyperhype/hyperscript>

## testing

```
prove6 -l

```

## license

MIT


## dist_zef-lizmat-CLI-Help.md
[![Actions Status](https://github.com/lizmat/CLI-Help/actions/workflows/test.yml/badge.svg)](https://github.com/lizmat/CLI-Help/actions)

# NAME

CLI::Help - add -h / --help parameters to your script

# SYNOPSIS

```
proto sub MAIN(|) {*}
use CLI::Help %?RESOURCES, &MAIN;

sub handler($text, @subsections, :$verbose) {
    say "Help for foo @subsections";
    say $text;
    say "Verbose version" if $verbose;
}
use CLI::Help %?RESOURCES, &MAIN, &handler;

use CLI::Help %?RESOURCES, &MAIN, &handler, 'long-only';

```

# DESCRIPTION

CLI::Help adds a `multi sub` candidate to the `&MAIN` function in your script, that will trigger if the script is called with `-h` or `--help` named arguments **only**, and any positional arguments.

For instance, in the [App::Rak](https://raku.land/zef:lizmat/App::Rak) distribution, which provides a `rak` CLI, calling `rak --help` will result in something like:

```
$ rak --help
rak - a CLI for searching strings in files and more
---------------------------------------------------
...

```

And calling `rak --help --verbose`

```
$ rak --help --verbose
rak - a CLI for searching strings in files and more
---------------------------------------------------
...

Provided by App::Rak - 0.0.14 by Elizabeth Mattijsen,
  implemented in the Raku® Programming Language 6.d,
  running on Rakudo™ 2022.06.55, built on Moar 2022.06.2.

Suggestions / bug reports / general comments are welcome at
  https://github.com/lizmat/App-Rak

Thank you for using rak!

```

By specifying a true value as the 4th argument in the `use` statement, will cause only `--help` to trigger the candidate.

# AUTHOR

Elizabeth Mattijsen [liz@raku.rocks](mailto:liz@raku.rocks)

Source can be located at: <https://github.com/lizmat/CLI-Help> . Comments and Pull Requests are welcome.

If you like this module, or what I’m doing more generally, committing to a [small sponsorship](https://github.com/sponsors/lizmat/) would mean a great deal to me!

# COPYRIGHT AND LICENSE

Copyright 2022 Elizabeth Mattijsen

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## exit.md
exit

Combined from primary sources listed below.

# [In Independent routines](#___top "go to top of document")[§](#(Independent_routines)_sub_exit "direct link")

See primary documentation
[in context](/type/independent-routines#sub_exit)
for **sub exit**.

```raku
multi exit()
multi exit(Int(Any) $status)
```

Exits the current process with return code `$status` or zero if no value has been specified. The exit value (`$status`), when different from zero, has to be opportunely evaluated from the process that catches it (e.g., a shell); it is the only way to return an exit code different from zero from a [Main](/routine/MAIN).

`exit` prevents the [LEAVE](/language/phasers#LEAVE) phaser to be executed, but it will run the code in the [`&*EXIT`](/language/variables#index-entry-%26*EXIT) variable.

`exit` should be used as last resort only to signal the parent process about an exit code different from zero, and not to terminate exceptionally a method or a sub: use [exceptions](/language/exceptions) instead.

The first call of `exit` in a process sets the return code, regardless of any subsequent calls to `exit` in the same, or any other thread.


## dist_zef-lizmat-P5lc.md
[![Actions Status](https://github.com/lizmat/P5lc/workflows/test/badge.svg)](https://github.com/lizmat/P5lc/actions)

# NAME

Raku port of Perl's lc() / uc() built-ins

# SYNOPSIS

```
use P5lc;

say lc "FOOBAR"; # foobar
with "ZIPPO" {
    say lc();  # zippo, may need to use parens to avoid compilation error
}

say uc "foobar"; # FOOBAR
with "zippo" {
    say uc();  # ZIPPO, may need to use parens to avoid compilation error
}

```

# DESCRIPTION

This module tries to mimic the behaviour of Perl's `lc` / `uc` built-ins as closely as possible in the Raku Programming Language.

# ORIGINAL PERL 5 DOCUMENTATION

```
lc EXPR
lc      Returns a lowercased version of EXPR. This is the internal
        function implementing the "\L" escape in double-quoted strings.

        If EXPR is omitted, uses $_.

        What gets returned depends on several factors:

        If "use bytes" is in effect:
            The results follow ASCII rules. Only the characters "A-Z"
            change, to "a-z" respectively.

        Otherwise, if "use locale" (but not "use locale
        ':not_characters'") is in effect:
            Respects current LC_CTYPE locale for code points < 256; and
            uses Unicode rules for the remaining code points (this last
            can only happen if the UTF8 flag is also set). See perllocale.

            Starting in v5.20, Perl wil use full Unicode rules if the
            locale is UTF-8. Otherwise, there is a deficiency in this
            scheme, which is that case changes that cross the 255/256
            boundary are not well-defined. For example, the lower case of
            LATIN CAPITAL LETTER SHARP S (U+1E9E) in Unicode rules is
            U+00DF (on ASCII platforms). But under "use locale" (prior to
            v5.20 or not a UTF-8 locale), the lower case of U+1E9E is
            itself, because 0xDF may not be LATIN SMALL LETTER SHARP S in
            the current locale, and Perl has no way of knowing if that
            character even exists in the locale, much less what code point
            it is. Perl returns the input character unchanged, for all
            instances (and there aren't many) where the 255/256 boundary
            would otherwise be crossed.

        Otherwise, If EXPR has the UTF8 flag set:
            Unicode rules are used for the case change.

        Otherwise, if "use feature 'unicode_strings'" or "use locale
        ':not_characters'" is in effect:
            Unicode rules are used for the case change.

        Otherwise:
            ASCII rules are used for the case change. The lowercase of any
            character outside the ASCII range is the character itself.

uc EXPR
uc      Returns an uppercased version of EXPR. This is the internal
        function implementing the "\U" escape in double-quoted strings. It
        does not attempt to do titlecase mapping on initial letters. See
        "ucfirst" for that.

        If EXPR is omitted, uses $_.

        This function behaves the same way under various pragma, such as
        in a locale, as "lc" does.

```

# PORTING CAVEATS

In future language versions of Raku, it will become impossible to access the `$_` variable of the caller's scope, because it will not have been marked as a dynamic variable. So please consider changing:

```
lc;

```

to either:

```
lc($_);

```

or, using the subroutine as a method syntax, with the prefix `.` shortcut to use that scope's `$_` as the invocant:

```
.&lc;

```

# AUTHOR

Elizabeth Mattijsen [liz@raku.rocks](mailto:liz@raku.rocks)

If you like this module, or what I’m doing more generally, committing to a [small sponsorship](https://github.com/sponsors/lizmat/) would mean a great deal to me!

Source can be located at: <https://github.com/lizmat/P5lc> . Comments and Pull Requests are welcome.

# COPYRIGHT AND LICENSE

Copyright 2018, 2019, 2020, 2021, 2023 Elizabeth Mattijsen

Re-imagined from Perl as part of the CPAN Butterfly Plan.

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## dist_zef-jforget-Date-Calendar-Strftime.md
# NAME

Date::Calendar::Strftime - formatting any Date object or any Date::Calendar::whatever object with 'strftime'

# SYNOPSIS

Using the `strftime` function with the core class Date:

```
use Date::Calendar::Strftime;
my  Date $last-day .= new(2019, 12, 31);

say strftime($last-day, "%Y-%m-%d ('ISO' date %G-W%V-%u)");
# --> 2019-12-31 ('ISO' date 2020-W01-2)

```

Using the `strftime` method with a Date::Calendar::xxx class (here, the French Revolutionary one):

```
use Date::Calendar::FrenchRevolutionary;
my  Date::Calendar::FrenchRevolutionary $Bonaparte's-coup-fr;
$Bonaparte's-coup-fr .= new(year => 8, month => 2, day => 18);

say $Bonaparte's-coup-fr.strftime("%Y-%m-%d");
# ---> "0008-02-18" for 18 Brumaire VIII

say $Bonaparte's-coup-fr.strftime("%A %e %B %EY");
# ---> "octidi 18 Brumaire VIII"

```

# INSTALLATION

```
zef install Date::Calendar::Strftime

```

or

```
git clone https://github.com/jforget/raku-Date-Calendar-Strftime.git
cd raku-Date-Calendar-Strftime
zef install .

```

# DESCRIPTION

Date::Calendar::Strftime is a role providing a `strftime` method and a `strftime` function to
format a string representing the date. This method is similar to the
`strftime` function in C.

The synopsis above shows examples with the standard class Date and
with specific class
Date::Calendar::FrenchRevolutionary, but Date::Calendar::Strftime can
be used with any Date::Calendar::xxxx class which implements the
attributes "year", "month" and "day". It can be used with a little
more effort with more esoteric Date::Calendar::xxxx classes.

# AUTHOR

Jean Forget

# COPYRIGHT AND LICENSE

Copyright (c) 2019, 2020, 2024, 2025 Jean Forget, all rights reserved

This library is free software; you can redistribute it and/or modify
it under the Artistic License 2.0.


## dist_zef-lizmat-Slangify.md
[![Actions Status](https://github.com/lizmat/Slangify/actions/workflows/linux.yml/badge.svg)](https://github.com/lizmat/Slangify/actions) [![Actions Status](https://github.com/lizmat/Slangify/actions/workflows/macos.yml/badge.svg)](https://github.com/lizmat/Slangify/actions) [![Actions Status](https://github.com/lizmat/Slangify/actions/workflows/windows.yml/badge.svg)](https://github.com/lizmat/Slangify/actions)

# NAME

Slangify - Provide an easy interface to activating slangs

# SYNOPSIS

```
# Code of a slang module with only a grammar change
role Foo::Grammar { ... }
use Slangify Foo::Grammar, Mu;

# Code of a slang module with both grammar and actions
role Foo::Grammar { ... }
role Foo::Actions { ... }
use Slangify Foo::Grammar, Foo::Actions;

# Code of a slang module with only an actions change
role Foo::Actions { ... }
use Slangify Mu, Foo::Actions;

# code of a slang module with legacy grammar
role Foo::Grammar { ... }
role Foo::Actions { ... }
role Foo::Grammar::Legacy { ... }
role Foo::Actions::Legacy { ... }
use Slangify Foo::Grammar, Foo::Actions,
  Foo::Grammar::Legacy, Foo::Actions::Legacy;

```

# DESCRIPTION

The `Slangify` module is a module intended for slang developers.

It abstracts the internals of slang creation and activation so that module developers of slangs have a consistent interface they can work with across current and future versions of the Raku Programming Language.

This module is **only** needed to install a module that provides a slang. And as such, would only need to be specified in the `build-depends` section of the META information.

Note that the absence of a grammar role or an actions role, can be indicated by specifying `Mu`. Sadly, some core ideosyncracies make it currently impossible to indicate no change otherwise.

If the given grammar / actions can work with both the legacy grammar, as well as with the new RakuAST based grammar, then no changes are needed. If there **is** a different grammar for the legacy grammar and/or actions for the legacy grammar, then you can specify these as the 3rd and 4th argument in the `use Slangify` statement.

# ADDITIONAL EXPORTS

The `Slangify` module also exports special candidates for postcircumfix `{ }` and for prefix `~`. This allows slang developers to remain closer to original grammar code which is often living in NQP land, e.g.: `~$<identifier> eq 'foo'`. Without these special candidates, slang developers would need to resort to using NQP ops.

# AUTHOR

Elizabeth Mattijsen [liz@raku.rocks](mailto:liz@raku.rocks)

Source can be located at: <https://github.com/lizmat/Slangify> . Comments and Pull Requests are welcome.

If you like this module, or what I’m doing more generally, committing to a [small sponsorship](https://github.com/sponsors/lizmat/) would mean a great deal to me!

# COPYRIGHT AND LICENSE

Copyright 2023, 2025 Elizabeth Mattijsen

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## dist_zef-leont-sigpipe.md
[![Actions Status](https://github.com/Leont/sigpipe/workflows/test/badge.svg)](https://github.com/Leont/sigpipe/actions)

# NAME

sigpipe - set up SIGPIPE correctly for CLI applications

# SYNOPSIS

```
use sigpipe;

```

# DESCRIPTION

Raku's default sigpipe handling does the sensible things for networking applications, but entirely the wrong thing for CLI applications. For example a program like `raku -e 'loop { say "y" }' | head` will output a long error message that is entirely useless for the end-user. This module will instead use the unix default: end the program immediately without any ceremony.

# AUTHOR

Leon Timmermans [fawaka@gmail.com](mailto:fawaka@gmail.com)

# COPYRIGHT AND LICENSE

Copyright 2022 Leon Timmermans

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## dist_cpan-UZLUISF-Pretty-Table.md
# Name

`Pretty::Table`, a simple Raku module to make it quick and easy to represent tabular data in visually appealing ASCII tables.

`Pretty::Table` is a port of the Python library [PTable](https://github.com/kxxoling/PTable).

**Disclaimer:** This module is still a work in progress. Although some basic features are implemented, they still require further testing.

# Synopsis

**Example 1**:

```
use Pretty::Table;

my $table = Pretty::Table.new:
    title => "Australian Cities",
    field-names => ["City name", "Area", "Population", "Annual Rainfall"],
    sort-by => 'Area',
    align => %('City name' => 'l'),
;

given $table {
    .add-row: ["Adelaide",  1295,  1158259,  600.5 ];
    .add-row: ["Brisbane",  5905,  1857594,  1146.4];
    .add-row: ["Darwin",    112,   120900,   1714.7];
    .add-row: ["Hobart",    1357,  205556,   619.5 ];
    .add-row: ["Sydney",    2058,  4336374,  1214.8];
    .add-row: ["Melbourne", 1566,  3806092,  646.9 ];
    .add-row: ["Perth",     5386,  1554769,  869.4 ];
}

say $table;

```

Output:

```
+—————————————————————————————————————————————————+
|                Australian Cities                |
+———————————+——————+————————————+—————————————————+
| City name | Area | Population | Annual Rainfall |
+———————————+——————+————————————+—————————————————+
| Darwin    | 112  |   120900   |      1714.7     |
| Adelaide  | 1295 |  1158259   |      600.5      |
| Hobart    | 1357 |   205556   |      619.5      |
| Melbourne | 1566 |  3806092   |      646.9      |
| Sydney    | 2058 |  4336374   |      1214.8     |
| Perth     | 5386 |  1554769   |      869.4      |
| Brisbane  | 5905 |  1857594   |      1146.4     |
+———————————+——————+————————————+—————————————————+

```

**Example 2**:

```
use Pretty::Table;

my $table = Pretty::Table.new;

given $table {
    .add-column('Planet', ['Earth', 'Mercury', 'Venus', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune']);
    .add-column('Position', [3, 1, 2, 4, 5, 6, 7, 8])
    .add-column('Known Satellites', [1, 0, 0, 2, 79, 82, 27, 14]);
    .add-column('Orbital period (days)', [365.256, 87.969, 224.701, 686.971, 4332.59, 10_759.22, 30_688.5, 60_182.0]);
    .add-column('Surface gravity (m/s)', [9.806, 3.7, 8.87, 3.721, 24.79, 10.44, 8.69, 11.15]);
}

$table.title('Planets in the Solar System');
$table.align(%(:Planet<l>));
$table.float-format(%('Orbital period (days)' => '-10.3f', 'Surface gravity (m/s)' => '-5.3f'));
$table.sort-by('Position');
$table.junction-char('*');

put $table;

```

Output:

```
*————————————————————————————————————————————————————————————————————*
|                    Planets in the Solar System                     |
*—————————*——————————*———————————————————————*———————————————————————*
| Planet  | Position | Orbital period (days) | Surface gravity (m/s) |
*—————————*——————————*———————————————————————*———————————————————————*
| Mercury |    1     |       87.969          |         3.700         |
| Venus   |    2     |       224.701         |         8.870         |
| Earth   |    3     |       365.256         |         9.806         |
| Mars    |    4     |       686.971         |         3.721         |
| Jupiter |    5     |       4332.590        |         24.790        |
| Saturn  |    6     |       10759.220       |         10.440        |
| Uranus  |    7     |       30688.500       |         8.690         |
| Neptune |    8     |       60182.000       |         11.150        |
*—————————*——————————*———————————————————————*———————————————————————*

```

# Installation

Using zef:

```
zef install Pretty::Table

```

From source:

```
$ git clone
$ cd raku-pretty-table
$ zef install .

```

# Quickstart

`Pretty::Table` supports two kinds of usage:

## As a module

```
use Pretty::Table;
my $x = Pretty::Table.new;

```

Read the section **Getter and Setter Methods** to find about the public attributes and their respective methods. For the [tutorial](https://gitlab.com/uzluisf/raku-pretty-table/tree/master/doc/Pretty/Table/Tutorial.rakumod), run `p6doc Pretty::Table::Tutorial`.

## As a command-line tool

```
pt --csv somefile.csv

```

Run `pt` to get the full usage message.

# Methods

## Getter and Setter Methods

**NOTE**: These methods's names are the same as their respective attributes. To set a specific attribute during the instantiation of a `Pretty::Table` object, use its method's name. For instance, to set `title`, `Pretty::Table.new(title => "Table's title")`. Thus, all methods listed here have an associated attribute that can be set during object construction.

### multi method field-names

```
multi method field-names() returns Array

```

Return a list of field names.

### multi method field-names

```
multi method field-names(
    @values
) returns Nil

```

Set a list of field names.

### multi method align

```
multi method align() returns Hash

```

Return how the alignment of fields is controlled.

### multi method align

```
multi method align(
    $val
) returns Nil

```

Set how the alignment of fields is controlled. Either an alignment string (l, c, or r) or a hash of field-to-alignment pairs.

### multi method valign

```
multi method valign() returns Hash

```

Return how the vertical alignment of fields is controlled.

### multi method valign

```
multi method valign(
    $val
) returns Nil

```

Set how the vertical alignment of fields is controlled. Either an alignment string (t, m, or b) or a hash of field-to-alignment pairs.

### multi method max-width

```
multi method max-width() returns Pretty::Table::Constrains::NonNeg

```

Return the maximum width of fields.

### multi method max-width

```
multi method max-width(
    $val where { ... }
) returns Nil

```

Set the maximum width of fields.

### multi method min-width

```
multi method min-width() returns Hash

```

Return the minimum width of fields.

### multi method min-width

```
multi method min-width(
    $val where { ... }
) returns Nil

```

Set the minimum width of fields.

### multi method min-table-width

```
multi method min-table-width() returns Pretty::Table::Constrains::NonNeg

```

Return the minimum desired table width, in characters.

### multi method min-table-width

```
multi method min-table-width(
    $val where { ... }
) returns Mu

```

Set the minimum desired table width, in characters.

### multi method max-table-width

```
multi method max-table-width() returns Mu

```

Return the maximum desired table width, in characters.

### multi method max-table-width

```
multi method max-table-width(
    $val where { ... }
) returns Mu

```

Set the minimum desired table width, in characters.

### multi method fields

```
multi method fields() returns Array

```

Return the list of field names to include in displays.

### multi method fields

```
multi method fields(
    @values
) returns Mu

```

Return the list of field names to include in displays.

### multi method title

```
multi method title() returns Str

```

Return the table title (if existent).

### multi method title

```
multi method title(
    Str $val
) returns Mu

```

Set the table title.

### multi method start

```
multi method start() returns Pretty::Table::Constrains::NonNeg

```

Return the start index of the range of rows to print.

### multi method start

```
multi method start(
    $val where { ... }
) returns Mu

```

Set the start index of the range of rows to print.

### multi method end

```
multi method end() returns Mu

```

Return the end index of the range of rows to print.

### multi method end

```
multi method end(
    $val
) returns Mu

```

Set the end index of the range of rows to print.

### multi method sort-by

```
multi method sort-by() returns Mu

```

Return the name of field by which to sort rows.

### multi method sort-by

```
multi method sort-by(
    Str $val where { ... }
) returns Mu

```

Set the name of field by which to sort rows.

### multi method reverse-sort

```
multi method reverse-sort() returns Bool

```

Return the direction of sorting, ascending (False) vs descending (True).

### multi method reverse-sort

```
multi method reverse-sort(
    Bool $val
) returns Nil

```

Set the direction of sorting (ascending (False) vs descending (True).

### multi method sort-key

```
multi method sort-key() returns Callable

```

Return the sorting key function, applied to data points before sorting.

### multi method sort-key

```
multi method sort-key(
    &val
) returns Nil

```

Set the sorting key function, applied to data points before sorting.

### multi method header

```
multi method header() returns Bool

```

Return whether the table has a heading showing the field names.

### multi method header

```
multi method header(
    Bool $val
) returns Nil

```

Set whether the table has a heading showing the field names.

### multi method header-style

```
multi method header-style() returns Pretty::Table::Constrains::HeaderStyle

```

Return style to apply to field names in header ("cap", "title", "upper", or "lower").

### multi method header-style

```
multi method header-style(
    $val where { ... }
) returns Mu

```

Set style to apply to field names in header ("cap", "title", "upper", or "lower").

### multi method border

```
multi method border() returns Bool

```

Return whether a border is printed around table.

### multi method border

```
multi method border(
    Bool $val
) returns Mu

```

Set whether a border is printed around table.

### multi method hrules

```
multi method hrules() returns Pretty::Table::Constrains::HorizontalRule

```

Return how horizontal rules are printed after rows.

### multi method hrules

```
multi method hrules(
    $val where { ... }
) returns Mu

```

Set how horizontal rules are printed after rows. Allowed values: FRAME, ALL, HEADER, NONE

### multi method vrules

```
multi method vrules() returns Pretty::Table::Constrains::VerticalRule

```

Return how vertical rules are printed between columns.

### multi method vrules

```
multi method vrules(
    $val where { ... }
) returns Mu

```

Set how vertical rules are printed between columns. Allowed values: FRAME, ALL, NONE

### multi method int-format

```
multi method int-format() returns Mu

```

Return how the integer data is formatted.

### multi method int-format

```
multi method int-format(
    $val
) returns Nil

```

Set how the integer data is formatted. The value can either be a string or a hash of field-to-format pairs.

### multi method float-format

```
multi method float-format() returns Mu

```

Return how the integer data is formatted.

### multi method float-format

```
multi method float-format(
    $val
) returns Nil

```

Set how the integer data is formatted. The value can either be a string or a hash of field-to-format pairs.

### multi method padding-width

```
multi method padding-width() returns Pretty::Table::Constrains::NonNeg

```

Return the number of empty spaces between a column's edge and its content.

### multi method padding-width

```
multi method padding-width(
    $val where { ... }
) returns Nil

```

Set the number of empty spaces between a column's edge and its content.

### multi method left-padding-width

```
multi method left-padding-width() returns Pretty::Table::Constrains::NonNeg

```

Return the number of empty spaces between a column's left edge and its content.

### multi method left-padding-width

```
multi method left-padding-width(
    $val where { ... }
) returns Nil

```

Set the number of empty spaces between a column's left edge and its content.

### multi method right-padding-width

```
multi method right-padding-width() returns Pretty::Table::Constrains::NonNeg

```

Return the number of empty spaces between a column's right edge and its content.

### multi method right-padding-width

```
multi method right-padding-width(
    $val where { ... }
) returns Nil

```

Set the number of empty spaces between a column's right edge and its content.

### multi method vertical-char

```
multi method vertical-char() returns Pretty::Table::Constrains::Char

```

Return character used when printing table borders to draw vertical lines.

### multi method vertical-char

```
multi method vertical-char(
    $val where { ... }
) returns Nil

```

Return character used when printing table borders to draw vertical lines.

### multi method horizontal-char

```
multi method horizontal-char() returns Pretty::Table::Constrains::Char

```

Return character used when printing table borders to draw horizontal lines.

### multi method horizontal-char

```
multi method horizontal-char(
    $val where { ... }
) returns Nil

```

Return character used when printing table borders to draw horizontal lines.

### multi method junction-char

```
multi method junction-char() returns Pretty::Table::Constrains::Char

```

Return character used when printing table borders to draw line junctions.

### multi method junction-char

```
multi method junction-char(
    $val where { ... }
) returns Nil

```

Return character used when printing table borders to draw line junctions.

### multi method format

```
multi method format() returns Bool

```

Return whether or not HTML tables are formatted to match styling options.

### multi method format

```
multi method format(
    Bool $val
) returns Nil

```

Set whether or not HTML tables are formatted to match styling options.

### multi method print-empty

```
multi method print-empty() returns Bool

```

Return whether or not empty tables produce a header and frame or just an empty string.

### multi method print-empty

```
multi method print-empty(
    Bool $val
) returns Nil

```

Set whether or not empty tables produce a header and frame or just an empty string.

### multi method old-sort-slice

```
multi method old-sort-slice() returns Bool

```

Return whether to slice rows before sorting in the "old style".

### multi method old-sort-slice

```
multi method old-sort-slice(
    Bool $val
) returns Nil

```

Return whether to slice rows before sorting in the "old style".

## Style of Table

### method set-style

```
method set-style(
    TableStyle $style
) returns Nil

```

Set the style to be used for the table. Allowed values: DEFAULT: Show header and border, hrules and vrules are FRAME and ALL respectively, paddings are 1, vert. char is |, hor. char is -, and junction char is +. MSWORD-FRIENDLY: Show header and border, hrules is NONE, paddings are 1, and vert. char is | PLAIN-COLUMNS: Show header and hide border, hrules is NONE, padding is 1, left padding is 0, and right padding is 8 RANDOM: random style

## Data Input Methods

### method add-row

```
method add-row(
    @row
) returns Nil

```

Add a row to the table.

## class Mu $

Row of data, should be a list with as many elements as the table has fields.

### method del-row

```
method del-row(
    Int $row-index
) returns Nil

```

Delete a row from the table.

## class Mu $

Index of the row to delete (0-based index).

### method add-column

```
method add-column(
    Str $fieldname,
    @column,
    $align where { ... } = "c",
    $valign where { ... } = "m"
) returns Nil

```

Add a column to the table.

## class Mu $

Name of the field to contain the new column of data.

## class Mu $

Column of data, should be a list with as many elements as the table has rows.

## class Mu $

Desired alignment for this column - "l" (left), "c" (center), and "r" (right).

## class Mu $

Desired vertical alignment for new columns - "t" (top), "m" (middle), and "b" (bottom).

### method clear-rows

```
method clear-rows() returns Nil

```

Delete all rows from the table but keep the current field names.

### method clear

```
method clear() returns Nil

```

Delete all rows and field names from the table, maintaining nothing but styling options.

## Plain Text String methods

### method get-string

```
method get-string(
    Str :$title = Str,
    :$start where { ... } = Pretty::Table::Constrains::NonNeg,
    :$end where { ... } = Pretty::Table::Constrains::NonNeg,
    :@fields,
    Bool :$header = Bool,
    Bool :$border = Bool,
    :$hrules where { ... } = Pretty::Table::Constrains::HorizontalRule,
    :$vrules where { ... } = Pretty::Table::Constrains::VerticalRule,
    Str :$int-format = Str,
    Str :$float-format = Str,
    :$padding-width where { ... } = Pretty::Table::Constrains::NonNeg,
    :$left-padding-width where { ... } = Pretty::Table::Constrains::NonNeg,
    :$right-padding-width where { ... } = Pretty::Table::Constrains::NonNeg,
    :$vertical-char where { ... } = Pretty::Table::Constrains::Char,
    :$horizontal-char where { ... } = Pretty::Table::Constrains::Char,
    :$junction-char where { ... } = Pretty::Table::Constrains::Char,
    Str :$sort-by = Str,
    :&sort-key,
    Bool :$reverse-sort = Bool,
    Bool :$old-sort-slice = Bool,
    Bool :$print-empty = Bool
) returns Str

```

Return string representation of table in current state.

## class Mu $

See method title

## class Mu $

See method start

## class Mu $

See method end

## class Mu $

See method fields

## class Mu $

See method header

## class Mu $

See method border

## class Mu $

See method hrules

## class Mu $

See method vrules

## class Mu $

See method int-format

## class Mu $

See method float-format

## class Mu $

See method padding-width

## class Mu $

See method left-padding-width

## class Mu $

See method right-padding-width

## class Mu $

See method vertical-char

## class Mu $

See method horizontal-char

## class Mu $

See method junction-char

## class Mu $

See method sort-by

## class Mu $

See method sort-key

## class Mu $

See method reverse-sort

## class Mu $

see method old-sort-slice

## class Mu $

See method print-empty

## Miscellaneous Methods

### method row-count

```
method row-count() returns Int

```

Return the number of rows.

### method col-count

```
method col-count() returns Int

```

Return the number of columns.


## dist_zef-lizmat-App-Raku-Log.md
[![Actions Status](https://github.com/lizmat/App-Raku-Log/workflows/test/badge.svg)](https://github.com/lizmat/App-Raku-Log/actions)

# NAME

App::Raku::Log - Cro application for presenting Raku IRC logs

# SYNOPSIS

```
$ ./start

$ ./start logs base

```

# DESCRIPTION

App::Raku::Log is ...

# AUTHOR

Elizabeth Mattijsen [liz@wenzperl.nl](mailto:liz@wenzperl.nl)

Source can be located at: <https://github.com/lizmat/App-Raku-Log> . Comments and Pull Requests are welcome.

# COPYRIGHT AND LICENSE

Copyright 2021 Elizabeth Mattijsen

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## dist_zef-librasteve-Cro-WebApp-Evaluate.md
# Cro::WebApp::Evaluate

so, basically this does the same as `<?php mycode ?>` does for php in html web content

sorry!

# SYNOPSIS

Routes.rakumod

```
use Cro::HTTP::Router;
use Cro::WebApp::Template;
use Cro::WebApp::Evaluate;

sub routes() is export {
    route {
        evaluate-location 'evaluates';

        get -> {
            evaluate 'index.raku';
        }

        get -> *@path {
                static 'static', @path;
        }
    }
}

```

index.raku

```
<body>

<div class="container">
    <h1>Welcome to My Simple Raku Page!</h1>

    <p>
        Today is:
        <?raku
            #Get the current date and time
            use DateTime::Format;
            say strftime('%Y-%m-%d %H:%M:%S', DateTime.now);
        ?>
    </p>

    <p>
        Random number:
        <?raku
            #Generate a random number between 1 and 100
            say (^100).pick;
        ?>
    </p>
</div>

</body>

```

# GETTING STARTED

Install raku - eg. from [rakubrew](https://rakubrew.org), then:

#### Install Cro

* `zef install --/test cro`
* `zef install Cro::WebApp`

#### Install this repo

* `git clone https://github.com/librasteve/raku-Cro-WebApp-Evaluate.git`
* `cd raku-Cro-WebApp-Evaluate` && `zef install .`

#### Make a Cro server

* `cro stub http examples examples` (OK all the defaults)
* `cp -R example evaluates static templates ./examples`

#### Run and view it

* `cd examples` && `cro run`
* Open a browser and go to `http://localhost:20000`

You will note that cro has many other options as documented at [Cro](https://cro.raku.org) if you want to deploy to a production server.

# DESCRIPTION

Cro::WebApp::Evaluate provides classis syntax to Cro.

# AUTHOR

librasteve [librasteve@furnival.net](mailto:librasteve@furnival.net)

# COPYRIGHT AND LICENSE

Copyright 2024 librasteve

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## dist_github-vendethiel-Serialize-Tiny.md
# Serialize::Tiny

A very bare-bones module that serializes an instance's public attributes.

### Examples

```
class A {
  has $.pub;
  has $!priv;
}

use Serialize::Tiny;
say serialize(A.new(:5pub));
#=> {pub = 5}

```


## buf.md
role Buf

Mutable buffer for binary data

```raku
role Buf[::T = uint8] does Blob[T] is repr('VMArray') is array_type(T){ ... }
```

A `Buf` does the role of a mutable sequence of (usually unsigned) integers.

```raku
my $bú = Buf.new(1, 2, 3);
$bú[1] = 42;
say $bú.raku; # OUTPUT: «Buf.new(1,42,3)␤»
```

However, it's a parameterized type, and you can instantiate with several integer types:

```raku
my $bú = Buf[int32].new(3, -3, 0xff32, -44);
say $bú; # OUTPUT: «Buf[int32]:0x<03 -3 FF32 -2C>␤»
```

By default, `Buf` uses 8-bit unsigned integers, that is, it is equivalent to Buf[uint8]. Some other types of `Buf`s which are used often get their own class name.

|  |  |
| --- | --- |
| buf8 | Buf[uint8] |
| buf16 | Buf[uint16] |
| buf32 | Buf[uint32] |
| buf64 | Buf[uint64] |

You can use these the same way you would with `Buf`:

```raku
my $bú = buf8.new(3, 6, 254);
say $bú; # OUTPUT: «Buf[uint8]:0x<03 06 fe>␤»
```

There are some methods on other objects, e.g. [`encode`](/type/Str#method_encode) that might return a `buf8` in some cases where it is the best representation for a particular encoding.

# [Methods](#role_Buf "go to top of document")[§](#Methods "direct link")

## [method subbuf-rw](#role_Buf "go to top of document")[§](#method_subbuf-rw "direct link")

```raku
method subbuf-rw($from = 0, $elems = self.elems - $from) is rw
```

A mutable version of `subbuf` that returns a [`Proxy`](/type/Proxy) functioning as a writable reference to a part of a buffer. Its first argument, `$from` specifies the index in the buffer from which a substitution should occur, and its last argument, `$elems` specifies how many elements are to be replaced.

For example, to replace one element at index 3 with two elements, `100` and `101`:

```raku
my Buf $bú .= new(0..5);
$bú.subbuf-rw(3,1) = Buf.new(100, 101);
say $bú.raku;   # OUTPUT: «Buf.new(0,1,2,100,101,4,5)␤»
```

In the case the `$elems` argument is not specified, the substitution happens at the specified index `$from` removing all trailing elements:

```raku
my Buf $bú .= new(0..5);
$bú.subbuf-rw(3) = Buf.new(200);
say $bú.raku;   # OUTPUT: «Buf.new(0,1,2,200)␤»
```

In the case the `$from` argument is not specified, the substitution happens from the very beginning of the buffer:

```raku
my Buf $bú .= new(0..5);
$bú.subbuf-rw = Buf.new(123, 123);
say $bú.raku;   # OUTPUT: «Buf.new(123, 123)␤»
```

## [routine subbuf-rw](#role_Buf "go to top of document")[§](#routine_subbuf-rw "direct link")

```raku
multi subbuf-rw(Buf:D \b) is rw
multi subbuf-rw(Buf:D \b, Int() $from) is rw
multi subbuf-rw(Buf:D \b, $from, $elems) is rw
```

Returns a writable reference to a part of a buffer. Invokes the `subbuf-rw` method on the specified `Buf`:

```raku
my Buf $bú .= new(1,2,3);
subbuf-rw($bú,2,1) = Buf.new(42);
say $bú.raku;   # OUTPUT: «Buf.new(1,2,42)␤»
```

## [method reallocate](#role_Buf "go to top of document")[§](#method_reallocate "direct link")

```raku
method reallocate(Buf:D: Int:D $elems)
```

Change the number of elements of the `Buf`, returning the changed `Buf`. The size of `Buf` will be adapted depending on the number of `$elems` specified: if it is smaller than the actual size of the `Buf` the resulting `Buf` will be shrunk down, otherwise it will be enlarged to fit the number of `$elems`. In the case the `Buf` is enlarged, newly created items will be assigned a Virtual Machine specific null value, therefore you should not rely upon their value since it could be inconsistent across different virtual machines.

```raku
my Buf $bú .= new(^10);
$bú.reallocate(5);
say $bú.raku;  # OUTPUT: «Buf.new(0,1,2,3,4)␤»

$bú = Buf.new( 1..3 );
$bú.reallocate( 10 );
say $bú.raku; # OUTPUT: «Buf.new(1,2,3,0,0,0,0,0,0,0)␤»
```

## [method list](#role_Buf "go to top of document")[§](#method_list "direct link")

```raku
multi method list(Buf:D:)
```

Returns a [`List`](/type/List) of integers.

```raku
say Buf.new(122,105,112,205).list; # OUTPUT: «(122 105 112 205)␤»
```

## [method push](#role_Buf "go to top of document")[§](#method_push "direct link")

```raku
method push( $elems )
```

Adds elements at the end of the buffer.

```raku
my $bú = Buf.new( 1, 1, 2, 3, 5 );
$bú.push( 8 );
say $bú.raku; # OUTPUT: «Buf.new(1,1,2,3,5,8)␤»
```

## [method pop](#role_Buf "go to top of document")[§](#method_pop "direct link")

```raku
method pop()
```

Returns and removes the last element of the buffer.

```raku
my $bú = Buf.new( 1, 1, 2, 3, 5 );
say $bú.pop(); # OUTPUT: «5␤»
say $bú.raku;  # OUTPUT: «Buf.new(1,1,2,3)␤»
```

## [method append](#role_Buf "go to top of document")[§](#method_append "direct link")

```raku
method append( $elems )
```

Appends to the end of the buffer.

```raku
my $bú = Buf.new( 1, 1, 2, 3, 5 );
$bú.append(9, 8, 7, 6);
say $bú.raku; # OUTPUT: «Buf.new(1,1,2,3,5,9,8,7,6)␤»
```

## [method prepend](#role_Buf "go to top of document")[§](#method_prepend "direct link")

```raku
method prepend( $elems )
```

Inserts elements at the beginning of the buffer.

```raku
my $bú = Buf.new( 1, 1, 2, 3, 5 );
$bú.prepend( 0 );
say $bú.raku; # OUTPUT: «Buf.new(0,1,1,2,3,5)␤»
```

The difference from method `unshift` is that if you prepend a **single** array or list argument, `prepend` will flatten that array / list, whereas `unshift` prepends the list / array as just a single element.

## [method shift](#role_Buf "go to top of document")[§](#method_shift "direct link")

```raku
method shift()
```

Removes and returns the first element of the buffer.

```raku
my $bú = Buf.new( 1, 1, 2, 3, 5 );
say $bú.shift(); # OUTPUT: «1␤»
say $bú.raku;    # OUTPUT: «Buf.new(1,2,3,5)␤»
```

## [method unshift](#role_Buf "go to top of document")[§](#method_unshift "direct link")

```raku
method unshift()
```

Inserts elements at the beginning of the buffer.

```raku
my $bú = Buf.new( 1, 1, 2, 3, 5 );
$bú.unshift( 0 );
say $bú.raku; # OUTPUT: «Buf.new(0,1,1,2,3,5)␤»
```

## [method splice](#role_Buf "go to top of document")[§](#method_splice "direct link")

```raku
method splice( Buf:D: $start = 0, $elems?, *@replacement --> Buf)
```

Substitutes elements of the buffer by other elements, returning a buffer with the removed elements.

```raku
my $bú = Buf.new( 1, 1, 2, 3, 5 );
say $bú.splice:  0, 3, <3 2 1>;  # OUTPUT: «Buf:0x<01 01 02>␤»
say $bú.raku;                    # OUTPUT: «Buf.new(3,2,1,3,5)␤»
```

# [Methods on buf8 only (6.d, 2018.12 and later)](#role_Buf "go to top of document")[§](#Methods_on_buf8_only_(6.d,_2018.12_and_later) "direct link")

These methods are available on the `buf8` type only. They allow low level access to writing bytes to the underlying data and in different ways with regards to type (integer or floating point (num)), size (8, 16, 32, 64 or 128 bits), signed or unsigned (for integer values) and endianness (native, little and big endianness). These methods always return [`Nil`](/type/Nil).

Endianness must be indicated by using values of the [`Endian`](/type/Endian) enum as the **third** parameter to these methods. If no endianness is specified, `NativeEndian` will be assumed. Other values are `LittleEndian` and `BigEndian`.

The buffer will be automatically resized to support any bytes being written if it is not large enough yet.

## [method write-uint8](#role_Buf "go to top of document")[§](#method_write-uint8 "direct link")

```raku
method write-uint8(buf8:D: uint $pos, uint8 $value, $endian = NativeEndian --> Nil)
```

Writes an unsigned 8-bit integer value at the given position. The `$endian` parameter has no meaning, but is available for consistency.

## [method write-int8](#role_Buf "go to top of document")[§](#method_write-int8 "direct link")

```raku
method write-int8(buf8:D: uint $pos, int8 $value, $endian = NativeEndian --> Nil)
```

Writes a signed 8-bit integer value at the given position. The `$endian` parameter has no meaning, but is available for consistency.

## [method write-uint16](#role_Buf "go to top of document")[§](#method_write-uint16 "direct link")

```raku
method write-uint16(buf8:D: uint $pos, uint16 $value, $endian = NativeEndian --> Nil)
```

Writes an unsigned 16-bit integer value at the given position with the given endianness.

## [method write-int16](#role_Buf "go to top of document")[§](#method_write-int16 "direct link")

```raku
method write-int16(buf8:D: uint $pos, int16 $value, $endian = NativeEndian --> Nil)
```

Writes a signed 16-bit integer value at the given position with the given endianness.

## [method write-uint32](#role_Buf "go to top of document")[§](#method_write-uint32 "direct link")

```raku
method write-uint32(buf8:D: uint $pos, uint32 $value, $endian = NativeEndian --> Nil)
```

Writes an unsigned 32-bit integer value at the given position with the given endianness.

## [method write-int32](#role_Buf "go to top of document")[§](#method_write-int32 "direct link")

```raku
method write-int32(buf8:D: uint $pos, int32 $value, $endian = NativeEndian --> Nil)
```

Writes a signed 32-bit integer value at the given position with the given endianness.

## [method write-uint64](#role_Buf "go to top of document")[§](#method_write-uint64 "direct link")

```raku
method write-uint64(buf8:D: uint $pos, uint64 $value, $endian = NativeEndian --> Nil)
```

Writes an unsigned 64-bit integer value at the given position with the given endianness.

## [method write-int64](#role_Buf "go to top of document")[§](#method_write-int64 "direct link")

```raku
method write-int64(buf8:D: uint $pos, Int:D $value, $endian = NativeEndian --> Nil)
```

Writes a signed 64-bit integer value at the given position with the given endianness.

## [method write-uint128](#role_Buf "go to top of document")[§](#method_write-uint128 "direct link")

```raku
method write-uint128(buf8:D: uint $pos, UInt:D $value, $endian = NativeEndian --> Nil)
```

Writes an unsigned 128-bit integer value at the given position with the given endianness.

## [method write-int128](#role_Buf "go to top of document")[§](#method_write-int128 "direct link")

```raku
method write-int128(buf8:D: uint $pos, Int:D $value, $endian = NativeEndian --> Nil)
```

Writes a signed 128-bit integer value at the given position with the given endianness.

## [method write-num32](#role_Buf "go to top of document")[§](#method_write-num32 "direct link")

```raku
method write-num32(buf8:D: uint $pos, num32 $value, $endian = NativeEndian --> Nil)
```

Writes a native `num32` IEEE floating point value at the given position with the given endianness.

## [method write-num64](#role_Buf "go to top of document")[§](#method_write-num64 "direct link")

```raku
method write-num64(buf8:D: uint $pos, num64 $value, $endian = NativeEndian --> Nil)
```

Writes a native `num64` IEEE floating point value at the given position with the given endianness.

# [Methods on buf8 only (6.d, 2019.03 and later)](#role_Buf "go to top of document")[§](#Methods_on_buf8_only_(6.d,_2019.03_and_later) "direct link")

## [method write-ubits](#role_Buf "go to top of document")[§](#method_write-ubits "direct link")

```raku
method write-ubits(buf8:D: uint $pos, uint $bits, UInt:D $value --> Nil)
```

Writes an unsigned integer value to the **bits** from the given **bit** offset and given number of bits. The endianness of the bits is assumed to be `BigEndian`. Always returns Nil.

## [method write-bits](#role_Buf "go to top of document")[§](#method_write-bits "direct link")

```raku
method write-bits(buf8:D: uint $pos, uint $bits, Int:D $value --> Nil)
```

Writes a signed integer value for the **bits** from the given **bit** offset and given number of bits. The endianness of the bits is assumed to be `BigEndian`. Always returns Nil.

# [Methods on buf8 only (6.d, 2019.10 and later)](#role_Buf "go to top of document")[§](#Methods_on_buf8_only_(6.d,_2019.10_and_later) "direct link")

These methods are available on the `buf8` type only. They allow low level access to writing bytes to the underlying data and in different ways with regards to type (integer or floating point (num)), size (8, 16, 32, 64 or 128 bits), signed or unsigned (for integer values) and endianness (native, little and big endianness).

These methods can also be called on the `buf8` type object, in which case a new `buf8` object will be returned. Otherwise, the invocant will be returned to allow for easier chaining of operations on the `buf8` object. The buffer will be automatically resized to support any bytes being written if it is not large enough yet.

Endianness must be indicated by using values of the [`Endian`](/type/Endian) enum as the **third** parameter to these methods. If no endianness is specified, `NativeEndian` will be assumed. Other values are `LittleEndian` and `BigEndian`.

## [method write-uint8](#role_Buf "go to top of document")[§](#method_write-uint8_0 "direct link")

```raku
method write-uint8(buf8: uint $pos, uint8 $value, $endian = NativeEndian --> buf8:D)
```

Writes an unsigned 8-bit integer value at the given position. The `$endian` parameter has no meaning, but is available for consistency.

## [method write-int8](#role_Buf "go to top of document")[§](#method_write-int8_0 "direct link")

```raku
method write-int8(buf8: uint $pos, int8 $value, $endian = NativeEndian --> buf8:D)
```

Writes a signed 8-bit integer value at the given position. The `$endian` parameter has no meaning, but is available for consistency.

## [method write-uint16](#role_Buf "go to top of document")[§](#method_write-uint16_0 "direct link")

```raku
method write-uint16(buf8: uint $pos, uint16 $value, $endian = NativeEndian --> buf8:D)
```

Writes an unsigned 16-bit integer value at the given position with the given endianness.

## [method write-int16](#role_Buf "go to top of document")[§](#method_write-int16_0 "direct link")

```raku
method write-int16(buf8: uint $pos, int16 $value, $endian = NativeEndian --> buf8:D)
```

Writes a signed 16-bit integer value at the given position with the given endianness.

## [method write-uint32](#role_Buf "go to top of document")[§](#method_write-uint32_0 "direct link")

```raku
method write-uint32(buf8: uint $pos, uint32 $value, $endian = NativeEndian --> buf8:D)
```

Writes an unsigned 32-bit integer value at the given position with the given endianness.

## [method write-int32](#role_Buf "go to top of document")[§](#method_write-int32_0 "direct link")

```raku
method write-int32(buf8: uint $pos, int32 $value, $endian = NativeEndian --> buf8:D)
```

Writes a signed 32-bit integer value at the given position with the given endianness.

## [method write-uint64](#role_Buf "go to top of document")[§](#method_write-uint64_0 "direct link")

```raku
method write-uint64(buf8: uint $pos, uint64 $value, $endian = NativeEndian --> buf8:D)
```

Writes an unsigned 64-bit integer value at the given position with the given endianness.

## [method write-int64](#role_Buf "go to top of document")[§](#method_write-int64_0 "direct link")

```raku
method write-int64(buf8: uint $pos, Int:D $value, $endian = NativeEndian --> buf8:D)
```

Writes a signed 64-bit integer value at the given position with the given endianness.

## [method write-uint128](#role_Buf "go to top of document")[§](#method_write-uint128_0 "direct link")

```raku
method write-uint128(buf8: uint $pos, UInt:D $value, $endian = NativeEndian --> buf8:D)
```

Writes an unsigned 128-bit integer value at the given position with the given endianness.

## [method write-int128](#role_Buf "go to top of document")[§](#method_write-int128_0 "direct link")

```raku
method write-int128(buf8: uint $pos, Int:D $value, $endian = NativeEndian --> buf8:D)
```

Writes a signed 128-bit integer value at the given position with the given endianness.

## [method write-num32](#role_Buf "go to top of document")[§](#method_write-num32_0 "direct link")

```raku
method write-num32(buf8: uint $pos, num32 $value, $endian = NativeEndian --> buf8:D)
```

Writes a native `num32` IEEE floating point value at the given position with the given endianness.

## [method write-num64](#role_Buf "go to top of document")[§](#method_write-num64_0 "direct link")

```raku
method write-num64(buf8: uint $pos, num64 $value, $endian = NativeEndian --> buf8:D)
```

Writes a native `num64` IEEE floating point value at the given position with the given endianness.

## [method write-ubits](#role_Buf "go to top of document")[§](#method_write-ubits_0 "direct link")

```raku
method write-ubits(buf8: uint $pos, uint $bits, UInt:D $value --> buf8:D)
```

Writes an unsigned integer value to the **bits** from the given **bit** offset and given number of bits. The endianness of the bits is assumed to be `BigEndian`.

## [method write-bits](#role_Buf "go to top of document")[§](#method_write-bits_0 "direct link")

```raku
method write-bits(buf8: uint $pos, uint $bits, Int:D $value --> buf8:D)
```

Writes a signed integer value for the **bits** from the given **bit** offset and given number of bits. The endianness of the bits is assumed to be `BigEndian`.

## [method Blob](#role_Buf "go to top of document")[§](#method_Blob "direct link")

```raku
method Buf(Buf:D: --> Blob:D)
```

Available as of the 2021.06 Rakudo compiler release.

Coerces the invocant into an immutable [`Blob`](/type/Blob) object.

# [Typegraph](# "go to top of document")[§](#typegraphrelations "direct link")

Type relations for `Buf`

raku-type-graph

Buf
Buf

Blob
Blob

Buf->Blob

Positional
Positional

Stringy
Stringy

Blob->Positional

Blob->Stringy

[Expand chart above](/assets/typegraphs/Buf.svg)