## dist_cpan-UZLUISF-QM.md
# NAME

QM - A Raku module that implements the Quine–McCluskey (QM) algorithm for simplifying Boolean functions

# DESCRIPTION

The **Quine-McCluskey** algorithm is a simplification technique to systematically reach a minimal solution using a system of any `n` variables.

See the [tutorial](./tutorial.md) for more information about the algorithm which also has an example that walks through the algorithm. The same example can be found in [examples/ex01.p6](./examples/ex01.p6) as a Raku file.

The [Quine–McCluskey algorithm](https://en.wikipedia.org/wiki/Quine%E2%80%93McCluskey_algorithm) on Wikipedia.

# INSTALLATION

### Using zef:

```
zef update && zef install QM

```

### From source:

```
git clone git@gitlab.com:uzluisf/quine-mccluskey.git
cd quine-mccluskey && zef install .

```

# SYNOPSIS

The module is implemented in a OO-style. To apply the algorithm, an object of the `QM` must be instantiated through the `minterms`. The following code snippet showcases all the methods made available by `QM` using the example from the [tutorial](./tutorial.md):

```
use QM;

my @regular-minterms = 0, 1, 2, 5, 6, 7, 8, 9, 10, 14;
my @dont-care = [];

# the don't care conditions array is optional.
my $qm = QM.minterms(@regular-minterms, @dont-care);

put $qm.all-minterms.join(', ');      #=> 0, 1, 2, 5, 6, 7, 8, 9, 10, 14

put $qm.prime-implicants<all>;        #=> 011- 0-01 01-1 --10 -00- -0-0

put $qm.essential-prime-implicants;   #=> --10 -00-

put $qm.prime-implicants-chart.perl;
#=>
#`{
"0" => $["-00-", "-0-0"],
"1" => $["-00-", "0-01"],
"10" => $["--10", "-0-0"],
"14" => $["--10"],
"2" => $["--10", "-0-0"],
"5" => $["01-1", "0-01"],
"6" => $["--10", "011-"],
"7" => $["011-", "01-1"],
"8" => $["-00-", "-0-0"],
"9" => $["-00-"]
}

put $qm.prime-implicants-chart(:dec).perl;
#=>
# ([2, 6, 10, 14], [0, 2, 8, 10], [0, 1, 8, 9], [1, 5], [5, 7], [6, 7]).Seq

put $qm.reduced-boolean-expression;  #=> A'BD + CD' + B'C'

```

# METHODS

* `all-minterms` - Return both the regular minterms and the don't care conditions if provided.
* `prime-implicants` - Return all prime implicants for the boolean function, including the essential prime implicants.
* `essential-prime-implicants` - Return the essential prime implicants for the boolean function.
* `prime-implicants-chart` - Return a hash representing the Prime Implicant Chart (PIC) detailing the minterms and the prime implicants which cover them.

  * `prime-implicants-chart(:dec)` - Return a sequence of arrays of prime implicants as decimal numerals.
* `reduced-boolean-expression` - Return the minimal SoP for the boolean function.

# Materials

This modules was inspired by [int-main's Python script](https://github.com/int-main/Quine-McCluskey) implementing the algorithm and the paper [Programing implementation of the Quine-McCluskey method for minimization of Boolean expression](https://arxiv.org/abs/1410.1059).

# AUTHOR

Luis F. Uceta

# LICENSE

Artistic License 2.0


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

# NAME

hyperize - helper subs to hyperize iterables with defaults

# SYNOPSIS

```
use hyperize;

sub MAIN(:$batch, :$degree) {
    my @foo = ^1000;
    @foo.&hyperize($batch, $degree);  # don't worry about defaults
}

```

# DESCRIPTION

hyperize exports two subroutines to make it easier to handle defaults for `batch` and `degree` from e.g. CLI scripts. As such, these subs are intended to replace the `.hyper` and `.race` methods on `Iterable`s.

The problem with these methods, is that they (currently) do not take undefined values for their `:batch` and `:degree` arguments, forcing the caller to decide what sane defaults are. With the subroutines provided by this module, you don't have to worry about that as a developer of CLI scripts anymore.

If there is a `degree` specified, and its **1**, then the first argument (the invocant if used as `.&hyperize`) will be returned, as there will be no sense in trying to `hyper` or `race` anything.

# EXPORTED SUBROUTINES

## hyperize

```
@foo.&hyperize($batch).map: { ...  }

@foo.&hyperize($batch, $degree).map: { ...  }

```

The `hyperize` subroutine takes 2 or 3 arguments. The first argument is an `Iterable` on which a hyper sequence (aka `HyperSeq`) should be returned. This is then typically the invocant of a `.map` of `.grep`.

The second argument is the size of batches that should be used (aka the `:batch` argument to `.hyper`. If the value specified is undefined, then the default value for batches will be assumed (whatever that may be, as determined by the core).

The third argument is optional. It indicates the degrees of parallelization (aka the number of CPU cores to be used, aka the `:degree` argument to `.hyper`. If it is not specified, or the value specified is undefined, then the default value for degree will be assumed (whatever that may be, as determined by the core).

## racify

```
@foo.&racify($batch).map: { ...  }

@foo.&racify($batch, $degree).map: { ...  }

```

The same as `hyperize`, but will call the `.race` method (causing unordered results) rather than the `.hyper` method.

# AUTHOR

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

Source can be located at: <https://github.com/lizmat/hyperize> . 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, 2025 Elizabeth Mattijsen

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


## dist_github-moznion-Object-Container.md
[![Build Status](https://travis-ci.org/moznion/p6-Object-Container.svg?branch=master)](https://travis-ci.org/moznion/p6-Object-Container)

# NAME

Object::Container - A simple container for object for perl6

# SYNOPSIS

## Instance method

```
use Object::Container;

my $container = Object::Container.new;

$container.register('obj1', $obj1);
$container.register('obj2', $obj2);

$container.get('obj1');        # <= equals $obj1
$container.get('obj2');        # <= equals $obj2
$container.get('not-existed'); # <= equals Nil

```

## Class method (singleton)

```
use Object::Container;

Object::Container.register('obj1', $obj1);
Object::Container.register('obj2', $obj2);

Object::Container.get('obj1');        # <= equals $obj1
Object::Container.get('obj2');        # <= equals $obj2
Object::Container.get('not-existed'); # <= equals Nil

```

# DESCRIPTION

Object::Container is a simple container for object. A simple DI mechanism can be implemented easily by using this module. This module provides following features;

* Register object to container
* Find object from container
* Remove registered object from container
* Clear container

# METHODS

## `register(Str:D $name, Any:D $object)`

Registers the instantiated object with name in the container.

## `register(Str:D $name, Callable:D $initializer)`

Registers the `Callable` as initializer to instantiate the object with the name in the container. This method instantiates the object with calling `Callable`. This is a **lazy** way to instantiate; it means it defers instantiation (i.e. calling `Callable`) until `get(...)` is invoked.

```
my $container = Object::Container.new;
my $initializer = sub {
    # Reach here when `$container.get()` is called (only at once)
    return $something;
};
$container.register('obj-name', $initializer);

```

## `get(Str:D $name) returns Any`

Finds the registered object from the container by the name and return it. If the object is missing, it returns `Nil`.

## `remove(Str:D $name) returns Bool`

Removes the registered object from the container by the name. It returns whether the registered object was existed in the container or not.

## `clear()`

Clears the container. In other words, it rewinds the container to its initial state.

# Singleton pattern

If you use this module with class method (e.g. `Object::Container.register(...)`), this module handles the container as singleton object.

# AUTHOR

moznion [moznion@gmail.com](mailto:moznion@gmail.com)

# COPYRIGHT AND LICENSE

Copyright 2017- moznion

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


## dist_github-hankache-Acme-Cow.md
# Acme::Cow [Build Status](https://travis-ci.org/hankache/Acme-Cow) [Build status](https://ci.appveyor.com/project/hankache/acme-cow)

A Raku implementation of cowsay.

## Installation

To install with zef:

```
zef update
zef install Acme::Cow

```

## Examples

```
use Acme::Cow;

# Default
Cow::cow.new(initial-text => "Hello World!").display;

# Custom face
Cow::cow.new(initial-text => "Hello World!").set-face("stoned").display;

# Custom template
Cow::camelia.new(initial-text => "Hello World!").display;

# Custom template & Custom face
Cow::www.new(initial-text => "Hello World!").set-face("stoned").display;

```

## Using the binary

```
cow-say --help
cow-say --about
cow-say --message='Hello World'
cow-say --message='Hello World' --face='stoned'
cow-say --message='Hello World' --template='camelia'

```

## To Do

* Enhance the text formatter
* Add more templates
* Use Terminal::ANSIColor to make the output more appealing

## Author

Naoum Hankache [naoum88@gmail.com](mailto:naoum88@gmail.com)

## License

Artistic License 2.0


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

# NAME

Attribute::Predicate - add "is predicate" trait to Attributes

# SYNOPSIS

```
use Attribute::Predicate;

class Foo {
    has $.bar is predicate;         # adds method "has-bar"
    has $.baz is predicate<bazzy>;  # adds method "bazzy"
}

Foo.new(bar => 42).has-bar;    # True
Foo.new(bar => 42).bazzy;      # False

```

# DESCRIPTION

This module adds a `is predicate` trait to `Attributes`. It is similar in function to the "predicate" option of Perl's `Moo` and `Moose` object systems.

If specified without any additional information, it will create a method with the name "has-{attribute.name}". If a specific string is specified, then it will create the method with that given name.

The method in question will return a `Bool` indicating whether the attribute has a defined value.

# AUTHOR

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

Source can be located at: <https://github.com/lizmat/Attribute-Predicate> . 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, 2019, 2021, 2024, 2025 Elizabeth Mattijsen

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


## match.md
class X::Syntax::Variable::Match

Compilation error due to declaring a match variable

```raku
class X::Syntax::Variable::Match does X::Syntax { }
```

Syntax error thrown when a match variable like `$<thing>` was declared.

For example

```raku
my $<thing>;

```

dies with

｢text｣ without highlighting

```

```

===SORRY!===
Cannot declare a match variable

```

```

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

Type relations for `X::Syntax::Variable::Match`

raku-type-graph

Match
Match

Capture
Capture

Match->Capture

Cool
Cool

Match->Cool

Mu
Mu

Any
Any

Any->Mu

Capture->Any

Cool->Any

Grammar
Grammar

Grammar->Match

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


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

# NAME

Slang::Subscripts - Allow subscripts in identifiers, just as digits

# SYNOPSIS

```
use Slang::Subscripts;

my $x₁ = 42; say $x₁;  # 42

```

# DESCRIPTION

Slang::Subscripts modifies the Raku grammar to make it possible to use numeric subscripts ₀₁₂₃₄₅₆₇₈₉ at the end of identifiers.

# CREDITS

Idea shamelessly copied from Slang::Piersing by Tobias Leich.

# AUTHOR

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

Source can be located at: <https://github.com/lizmat/Slang-Subscripts> . 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 2019, 2021, 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-cro-Cro-HTTP.md
# Cro::HTTP Build Status

This is part of the Cro libraries for implementing services and distributed
systems in Raku. See the [Cro website](http://cro.services/) for further
information and documentation.


## dist_zef-raku-community-modules-String-FuzzyIndex.md
[![Actions Status](https://github.com/raku-community-modules/String-FuzzyIndex/actions/workflows/linux.yml/badge.svg)](https://github.com/raku-community-modules/String-FuzzyIndex/actions) [![Actions Status](https://github.com/raku-community-modules/String-FuzzyIndex/actions/workflows/macos.yml/badge.svg)](https://github.com/raku-community-modules/String-FuzzyIndex/actions) [![Actions Status](https://github.com/raku-community-modules/String-FuzzyIndex/actions/workflows/windows.yml/badge.svg)](https://github.com/raku-community-modules/String-FuzzyIndex/actions)

# NAME

String::FuzzyIndex - Fuzzy index routine based on Smith-Waterman algorithm

# SYNOPSIS

```
use String::FuzzyIndex;

my @fzmatch = fzindex($haystack, $needle);

my @fzmatch = fzindex($haystack, $needle, :s_id(6), :s_ocr(3), :s_gap(-1), :s_nid(-1));
my @fzmatch = fzindex($haystack, $needle, :ignore_diacritics);
my @fzmatch = fzindex($haystack, $needle, :glossover_ocrerrors);

```

# DESCRIPTION

`String::FuzzyIndex` is a pure Raku module for fuzzy string matchingi based on the [Smith-Waterman algorithm](https://en.wikipedia.org/wiki/Smith%E2%80%93Waterman_algorithm). It provides a single subroutine named `fzindex`.

# SUBROUTINES

## fzindex

The subroutine locates the best match(es) of a needle string in a haystack string and returns the best-match data in the form of a `List`. In case no best match was found, the `List` is empty. Otherwise the returned `List` contains, for each best match, an eight-element sub-`List` describing that match.

The structure of a sub-`List` is as follows:

|  |  |  |
| --- | --- | --- |
| Index | Type | Description |
| :------|:----------|:------------------------------------------------------------ |  |  |
| 0 | Rat | Match score as fraction of maximum score for perfect match |
| 1 | Int | Index of start position of match in haystack |
| 2 | Int | Index of end position of match in haystack |
| 3 | Int | Index of start position of match in needle |
| 4 | Int | Index of end position of match in needle |
| 5 | List[Str] | Traceback buffer for match in haystack |
| 6 | List[Str] | Traceback buffer for match in needle |
| 7 | List[Int] | Traceback buffer comprising the match's similarity scores |

### Similarity scoring scheme

The operation of `fzindex` is based on the [Smith-Waterman algorithm](https://en.wikipedia.org/wiki/Smith%E2%80%93Waterman_algorithm). This algorithm is used to identify the best match(es) by performing so-called 'local sequence alignment', i.e. by comparing segments of the haystack and the needle of all possible lengths, and optimizing a similarity measure.

In the process, individual characters from the haystack and the needle are pairwise compared and scored based on how similar they are. If two characters are identical, their alignment is assigned the similarity score `s_id`. If they are not identical, their alignment is assigned the similarity score `s_nid`, unless the options `ignore_diacritics` and/or `:glossover_ocrerrors` are used (see below).

The alignment of haystack and needle segments may also call for the acknowledgement of gaps: positions in an aligned segment that correspond to neither identical nor non-identical elements. To this end, `fzindex` implements a linear gap penalty scheme according to which each such gap is assigned a gap penalty `s_gap`. In the traceback buffers reported for a match, gaps are denoted with a dash ('-').

When working with strings extracted from OCRed data, mismatches in the alignment of segments may arise from the improper recognition of diacritics and/or the mixup of two characters. A 'ç' may, for instance, have been recognized as a 'c' and so frustrate alignment. Similarly, an 'I' is commonly OCRed as an 'l', or an '|'. `fzindex` offers two options to help mitigate such OCR-related issues:

* :ignore\_diacritics

Causes diacritics to be ignored in assessing whether two characters are identical. Hence, the pairwise comparison of 'ç' and 'c' results in assignment of the similarity score `s_id` rather than the score `s_nid`.

* :glossover\_ocrerrors

Causes the alignment of two characters that are commonly confused in OCR to be assigned the score `s_ocr` rather than the score `s_nid`.

The default scores, which may be changed using correspondingly named arguments, are as follows:

|  |  |  |
| --- | --- | --- |
| Score | Default value | Description |
| :------|:--------------:|:-------------------------------------------------------------- |  |  |
| s\_id | +6 | Score awarded to identical/matching characters |
| s\_ocr | +3 | Score awarded to possibly identical characters in OCR context |
| s\_gap | -1 | Penalty for a gap (a dash in the traceback buffer) |
| s\_nid | -1 | Score awarded to non-identical characters |

### Intended use The Raku built-in [`index`](https://docs.raku.org/type/Str#method_index) localizes the first perfect match of a needle within a haystack. It is fast, but when it comes up empty, one may be left wondering if either the haystack or the needle perhaps contains a typo, spelling variation, OCR error or the like that caused `index` to report the absence of the needle from the haystack. In such a case, `fzindex` may be used as a backup for `index`.

However, since `index` is comparably fast, `fzindex` internally executes an `index`-based (actually: [`indices`](https://docs.raku.org/type/Str#method_indices)-based) match attempt before starting a local sequence alignment attempt.

Because of this, there is generally no need to implement the use of `fzindex` as an actual backup to the use of the `index` built-in. Instead, the `fzindex` routine may be used instead of the built-in `index`. Such use of `fzindex` obviously comes at a performance penalty, but has the advantages that (i) all perfect matches are reported at once, and (ii) any best fuzzy matches are reported in case no perfect matches exist.

### Optimization

The Raku implementation of the Smith-Waterman algorithm is naturally relatively slow, and in the present version of `String::FuzzyIndex` no significant optimization attempt has been made. Should you need fuzzy string matching for a large number of lengthy strings, you are probably better off with an implementation in a low level language like C.

That said, some performance enhancing code has already been tested and is likely to appear in future versions.

### Example

```
use String::FuzzyIndex;

my $haystack  = 'The squeeky weel gets the grease.';
my $needle    = 'squeaky wheel';

my @r = fzindex($haystack, $needle);

say "{@r.elems} match(es) found.";
for @r -> ($score, $hsp, $hep, $nsp, $nep, $htb, $ntb, $stb) {
    say "Match score               : ", $score;
    say "Matching haystack portion : ", $haystack.substr: $hsp, ($hep-$hsp+1);
    say "Matching needle portion   : ", $needle.substr:   $nsp, ($nep-$nsp+1);
    say "Scoring traceback buffer  : ", $stb;
    say "Haystack traceback buffer : ", $htb;
    say "Needle traceback buffer   : ", $ntb;
}

```

```
1 match(es) found.
Match score               : 0.820513
Matching haystack portion : squeeky weel
Matching needle portion   : squeaky wheel
Scoring traceback buffer  : (6 12 18 24 23 29 35 41 47 46 52 58 64)
Haystack traceback buffer : (s q u e e k y   w - e e l)
Needle traceback buffer   : (s q u e a k y   w h e e l)

```

# AUTHOR

threadless-screw

# COPYRIGHT AND LICENSE

Copyright 2019 threadless-screw

Copyright 2024 Raku Community

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


## dist_cpan-ANTONOV-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.


## uniprops.md
uniprops

Combined from primary sources listed below.

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

See primary documentation
[in context](/type/Cool#sub_uniprops)
for **sub uniprops**.

```raku
sub uniprops(Str:D $str, Stringy:D $propname = "General_Category")
```

Interprets the invocant as a [`Str`](/type/Str), and returns the [unicode property](http://userguide.icu-project.org/strings/properties) for each character as a Seq. If no property is specified returns the [General Category](https://en.wikipedia.org/wiki/Unicode_character_property#General_Category). Returns a Bool for Boolean properties. Similar to [uniprop](/routine/uniprop), but for each character in the passed string.


## dist_cpan-UZLUISF-Markit.md
![Markit](https://i.imgur.com/QjwPsaf.png)

# Name

`Markit`, a Markdown parsing module for the [Raku](https://raku-lang.org) programming language.

# Synopsis

```
use Markit;
my $md = Markdown.new;
say $md.markdown("# Raku Rocks!"); # «<h1>Raku Rocks!</h1>␤»

```

# Description

This module parses Markdown (MD) and generates HTML from it.

## How does Markit work?

Similar to Parsedown, Markit tries to read a Markdown file like a human would. First, it looks at individual lines and check how the lines start in order to classify them into blocks of text (here a *block* is represented as a hash that contains information about the block of text. For instance, the block text, its type, the elements it contains, the routine it should be handled by, etc.). For example, if a line starts with a `*`, then it could be either a list's item (i.e., `li`) or a horizontal rule (i.e., `hr`). Once it recognizes the block, Markit continues to the line's content. As it reads, it watches out for special characters that helps it recognize inline elements (e.g., `*` for emphasis).

As stated in the Parsedown's repository, this is a "*line-based*" approach.

# Installation

Using `zef`:

```
zef update && zef install Markit

```

From source:

```
git clone git@gitlab.com:uzluisf/raku-markit.git
cd geuse && zef install .

```

# Exports

## Class

By default, `Markit` exports the `Markdown` class. The default instantiation

```
my $md-obj = Markdown.new;

```

is the same as

```
my $md-obj = Markdown.new:
    breaks-enabled =>  False,
    escape-markup  =>  False,
    urls-linked    =>  True,
    safe-mode      =>  False,
    strict-mode    =>  False
;

```

Or more succintly:

```
my $md-obj = Markdown.new:
    :!breaks-enabled,
    :!escape-markup,
    :urls-linked,
    :!safe-mode,
    :!strict-mode
;

```

### Methods

The `Markdown` class makes available only the `markdown` method which must be called on an instance of the class. The following are the method's different signatures:

* `markdown($text)` - Convert Markdown to HTML markup and return it.

  ```
  $md.markdown("# Raku Rocks!"); #=> <h1>Raku Rocks!</h1>

  ```

# Authors

* Luis F. Uceta, <https://gitlab.com/uzluisf>

# License

This module is a port of the PHP's Parsedown library written by Emanuil Rusev (<https://github.com/erusev>) and located at <https://github.com/erusev/parsedown>.

This program is free software; you can redistribute it and/or modify it under the Artistic License 2.0. See the LICENSE file included in this distribution for complete details.


## dist_github-jsimonet-Log-Any.md
[![Build Status](https://travis-ci.org/jsimonet/log-any.svg?branch=master)](https://travis-ci.org/jsimonet/log-any)
[![Build status](https://ci.appveyor.com/api/projects/status/rjhdnidc2hwnmd0p/branch/master?svg=true)](https://ci.appveyor.com/project/jsimonet/log-any/branch/master)

# NAME

Log::Any

# SYNOPSIS

```
use Log::Any;
use Log::Any::Adapter::Stdout;
use Log::Any::Adapter::Stderr;

# Basic usage
Log::Any.add( Log::Any::Adapter::Stdout.new, formatter => '\d \m' );
Log::Any.info( 'yolo' );
# OUTPUT: 2017-06-06T11:43:43.067909Z yolo

# Advanced usage
Log::Any.add( Log::Any::Adapter::Stderr.new,
              formatter => '\d \m',
              filters( [severity => '>=error'] ) );
Log::Any.add( Log::Any::Adapter::Stdout.new, formatter => '\d \m' );

# Will be logged on stderr
Log::Any.error( :category('security'), 'oups' );
# Will be logged on stdout
Log::Any.log( :msg('msg from app'), :category( 'network' ), :severity( 'info' ) );

```

# DESCRIPTION

Log::Any is a library to generate and handle application logs.
A log is a message indicating an application status at a given time. It has attributes, like a *severity* (error, warning, debug, …), a *category*, a *date* and a *message*.

These attributes are used by the *Formatter* to format the log and can also be used to filter logs and to choose where the log will be handled (via Adapters).

Like the Perl5 implementation (<https://metacpan.org/pod/Log::Any)>, the idea is to split log generation and log management.

## SEVERITY

The severity is the level of urgence of a log.
It can take the following values (based on Syslog):

* trace
* debug
* info
* notice
* warning
* error
* critical
* alert
* emergency

## CATEGORY

The category can be seen as a group identifier.

Ex:

* security ;
* database ;
* ...

*Default value* : the package name where the log is generated.

## DATE

The date is generated by Log::Any, and its values is the current date and time (ISO 8601).

## MESSAGE

A message is a string passed to Log::Any defined by the user. Newlines in message are escaped to prevent logging multi-line.

# ADAPTERS

An adapter handles a log by storing it, or sending it elsewhere.
If no adapters are defined, or no one meets the filtering, the message will not be logged.

A few examples:

* Log::Any::Adapter::File
* Log::Any::Adapter::Database::SQL
* Log::Any::Adapter::Stdout

## Provided adapters

### File

```
use Log::Any::Adapter::File;
Log::Any.add( Log::Any::Adapter::File.new( path => '/path/to/file.log' ) );

```

Starting with 0.9.5 version,, it's now possible to choose the buffering size to use, with *out-buffer*. This option can takes the same values as described in the perl6 documentation (<https://docs.perl6.org/routine/out-buffer)>.

### Stdout

```
use Log::Any::Adapter::Stdout;
Log::Any.add( Log::Any::Adapter::Stdout.new );

```

### Stderr

```
use Log::Any::Adapter::Stderr;
Log::Any.add( Log::Any::Adapter::Stderr.new );

```

# FORMATTERS

Often, logs need to be formatted to simplify the storage (time-series databases), or the analysis (grep, log parser).

Formatters will use the attributes of a Log.

| Symbol | Signification | Description | Default value |
| --- | --- | --- | --- |
| \d | Date (UTC) | The date on which the log was generated | Current date time |
| \c | Category | Can be any anything specified by the user | The current package/module |
| \s | Severity | Indicates if it's an information, or an error | none |
| \e{key} | Extra Field | Additional fields, used for formatting | none |
| \m | Message | Payload, explains what is going on | none |

*Note: Depending on the context or the configuration, some values can be empty.*

*Note: Extra fields uses a key in {} caracters to print associated value.*

```
use Log::Any::Adapter::Stdout;
Log::Any.add( Some::Adapter.new, :formatter( '\d \c \m \e{key1} \e{key2}' ) );

```

You can of course use variables in the formatter, but since *\* is already used in Perl6 strings interpolation, you have to escape them.

```
use Log::Any::Adapter::Stdout;
my $prefix = 'myapp ';
Log::Any.add( Log::Any::Adapter::Stdout.new, :formatter( "$prefix \\d \\c \\s \\m \\e\{key}" ) );

```

A formatter can be more complex than the default one by extending the class *Formatter*.

```
use Log::Any::Formatter;

class MyOwnFormatter is Log::Any::Formatter {
	method format( :$date-time!, :$msg!, :$category!, :$severity!, :%extra-fields ) {
		# Returns an Str
	}
}

```

# FILTERS

Filters can be used to allow a log to be handled by an adapter, to select which adapter to use or to use a different formatting string.
Many fields can be filtered, like the *category*, the *severity* or the *message*.

The easiest way to define a filter is by using the built-in *filter* giving an array to *filter* parameter:

```
Log::Any.add( Some::Adapter.new, :filter( [ <filters fields goes here>] ) );

```

## Filtering on category or message

```
# Matching by String
Log::Any.add( Some::Adapter.new, :filter( ['category' => 'My::Wonderfull::Lib' ] ) );
# Matching by Regex
Log::Any.add( Some::Adapter.new, :filter( ['category' => /My::*::Lib/ ] ) );

# Matching msg by Regex
Log::Any.add( Some::Adapter.new, :filter( [ 'msg' => /a regex/ ] );

```

## Filtering on severity

The severity can be considered as levels, so can be traited as numbers.

1. trace
2. debug
3. info
4. notice
5. warning
6. error
7. critical
8. alert
9. emergency

Filtering on severity can be done by specifying an operator in front of the severity:

```
filter => [ 'severity' => '<notice'   ] # Less
filter => [ 'severity' => '<=notice'  ] # Less or equal
filter => [ 'severity' => '==debug'   ] # Equality
filter => [ 'severity' => '!=notice'  ] # Inequality
filter => [ 'severity' => '>warning'  ] # Greater
filter => [ 'severity' => '>=warning' ] # Greater or equal

```

Matching only several severities is also possible:

```
filter => [ 'severity' => [ 'notice', 'warning' ] ]

```

## Several filters

If many filters are specified, all must be valid:

```
# Use this adapter only if the category is My::Wonderfull::Lib and if the severity is warning or error
[ 'severity' => '>=warning', 'category' => /My::Wonderfull::Lib/ ]

```

## Write your own filter

If a more complex filtering is necessary, a class inheriting Log::Any::Filter can be created:

```
# Use home-made filters
class MyOwnFilter is Log::Any::Filter {
	method filter( :$msg, :$severity, :$category, :%extra-fields ) returns Bool {
		# Write some complicated tests
		return True;
	}
}

Log::Any.add( Some::Adapter.new, :filter( MyOwnFilter.new ) );

```

## Filters acting like barrier

A filter generally authorize a log to be sent to an Adapter. If there is no defined Adapter, the log will end up in a black hole.

```
Log::Any.add( :filter( [ severity => '>warning' ] );
# Logs with severity above "warning" does not continue through the pipeline

```

# PIPELINES

A *pipeline* is a set of adapters, filters, formatters and options (asynchronicity) and can be used to define alternatives paths. This allows to handle differently some logs (for example, for security or realtime).
If a log is produced with a specific pipeline which is not defined in the log consumers, the default pipeline is used.

Pipelines can be specified when an Adapter is added.

```
Log::Any.add( :pipeline('security'), Log::Any::Adapter::Example.new );

Log::Any.error( :pipeline('security'), :msg('security error!' ) );

```

## ASYNCHRONICITY

By default, a pipeline is synchronous, but it can be asynchronous:

```
Log::Any.add( :pipeline( 'async pipeline'  ), Log::Any::Pipeline.new( :asynchronous ) );

```

If a pipeline of the specified name already exists, an exception will be throwed.
The *overwrite* parameter can be specified to force adding a new pipeline:

```
# Overwrite the default pipeline
Log::Any.add( Log::Any::Pipeline.new( :asynchronous ), :overwrite );
# Overwrite the "other" pipeline
Log::Any.add( Log::Any::Pipeline.new( :asynchronous ), :pipeline('other'), :overwrite );

```

**Asynchronous pipelines can contains messages to handle when a program reaches its end, so these messages will not be logged.**

## Continue on match

When adding an Adapter to the pipeline, `:continue-on-match` option can be specified.
This option tells the pipeline to continue to the next adapter if the Adapter is matched.

The log `info log twice` will be dispatched to both adapters.

```
Log::Any.add( :pipeline('continue-on-match'), SomeAdapterAs.new, :continue-on-match );
Log::Any.add( :pipeline('continue-on-match'), SomeAdapterB.new );
Log::Any.info( :pipeline('continue-on-match'), 'info log twice' );

```

# INTROSPECTION

Check if a log will be handled (to prevent computation of log).
It is usefull if you want to log a dump of a complex object which can take time.

## will-log method

This method can takes in parameters the *category*, the *severity* and the *pipeline* to use.
Theses parameters are then used to check if the message could pass through the pipelines and will be handled.

\*\* *msg* parameter cannot be tested, so if a filter acts on it, the results will differ between `will-log()` and `log()`. \*\*

```
if Log::Any.will-log( :severity('debug') ) {
	Log::Any.debug( serialize( $some-complex-object ) );
}

```

## will-log aliases methods

Some aliases are defined and provide the severity.

* will-emergency()
* …
* will-trace()

```
Log::Any.will-debug(); # Alias to will-log( :severity('debug') )

```

# DEBUGGING

## gist method

*gist* method prints a string represention of the internal Log::Any state (defined pipelines with their adapters, filters and formatters). Since many attributes are not public, you cannot recreate a Log::Any stack based on this representation.

# TODO

[TODO page](doc/todo.md)


## dist_zef-antononcube-DSL-Examples.md
# DSL::Examples

Raku data package with examples of DSL commands translations to programming code. (

The DSL examples are suitable for
[LLM few-shot training](https://www.prompthub.us/blog/the-few-shot-prompting-guide).
The sub `llm-example-function` provided by
["LLM::Functions"](https://github.com/antononcube/Raku-LLM-Functions), [AAp2],
can be effectively used to create translation functions utilizing those examples.

The utilization of such LLM-translation functions is exemplified below.
Also in the presentation ["Robust LLM pipelines (Mathematica, Python, Raku)"](https://youtu.be/QOsVTCQZq_s):

* [Short introduction](https://youtu.be/QOsVTCQZq_s?t=89)
* [Detailed explanations](https://www.youtube.com/watch?v=QOsVTCQZq_s&t=2840s)

Similar translations -- with much less computational resources -- are achieved with
grammar-based DSL translators; see
["DSL::Translators"](https://github.com/antononcube/Raku-DSL-Translators), [AAp1].

---

## Installation

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

```
zef install DSL::Examples;

```

From GitHub:

```
zef install https://github.com/antononcube/Raku-DSL-Examples.git

```

---

## Usage examples

Get all examples:

```
use DSL::Examples;
use Data::TypeSystem;

dsl-examples()
    ==> deduce-type()

```

```
# Assoc(Atom((Str)), Tuple([Assoc(Atom((Str)), Tuple([Assoc(Atom((Str)), Atom((Str)), 23), Assoc(Atom((Str)), Atom((Str)), 15)]), 2), Assoc(Atom((Str)), Tuple([Assoc(Atom((Str)), Atom((Str)), 20), Assoc(Atom((Str)), Atom((Str)), 17), Assoc(Atom((Str)), Atom((Str)), 27)]), 3)]), 2)

```

Get the examples for Latent Semantic Analysis (**LSA**) **Mon**adic pipeline segments in Python:

```
dsl-examples('Python', 'LSAMon')
    ==> deduce-type(:tally)

```

```
# Assoc(Atom((Str)), Atom((Str)), 15)

```

Make an LLM example function for translation of LSA workflow building commands:

```
use LLM::Functions;
my &llm-pipeline-segment = llm-example-function(dsl-examples()<WL><LSAMon>);

```

Run the LLM function over a list of DSL commands:

```
my @commands =
"use the dataset aAbstracts",
"make the document-term matrix without stemming",
"exract 40 topics using the method non-negative matrix factorization",
"show the topics";

@commands
.map({ .&llm-pipeline-segment })
.join("⟹\n")

```

```
# LSAMonUnit[aAbstracts]⟹
# LSAMonMakeDocumentTermMatrix["StemmingRules"->{}]⟹
# LSAMonExtractTopics["NumberOfTopics"->40,Method->"NNMF"]⟹
# LSAMonEchoTopicsTable[]

```

---

## References

### Packages

[AAp1] Anton Antonov,
[DSL::Translators Raku package](https://github.com/antononcube/Raku-DSL-Translators),
(2020-2024),
[GitHub/antononcube](https://github.com/antononcube).

[AAp2] Anton Antonov,
[LLM::Functions Raku package](https://github.com/antononcube/Raku-LLM-Functions),
(2023-2024),
[GitHub/antononcube](https://github.com/antononcube).

[AAp3] Anton Antonov,
[LLM::Prompts Raku package](https://github.com/antononcube/Raku-LLM-Prompts),
(2023-2024),
[GitHub/antononcube](https://github.com/antononcube).

### Videos

[AAv1] Anton Antonov,
["Robust LLM pipelines (Mathematica, Python, Raku)"](https://youtu.be/QOsVTCQZq_s),
(2024),
[YouTube/AAA4prediction](https://www.youtube.com/@AAA4prediction).


## dist_zef-raku-community-modules-WhereList.md
[![Actions Status](https://github.com/raku-community-modules/WhereList/actions/workflows/test.yml/badge.svg)](https://github.com/raku-community-modules/WhereList/actions)

# NAME

WhereList - Simpler `where` constraints for items of lists

# SYNOPSIS

```
use WhereList;

subset StrArray of Array where all-items Str, *.chars ≥ 3, *.contains: any <o a e>;

say [<foo bar meow>] ~~ StrArray; # OUTPUT: «True␤»
say ['dddrrrrrrrrr'] ~~ StrArray; # OUTPUT: «False␤»
say [<ha ha ha ha >] ~~ StrArray; # OUTPUT: «False␤»
say [<ooh come onn>] ~~ StrArray; # OUTPUT: «True␤»

class Foo {
    has @.bar where all-items any Str|Nil|Int:D, * === Any
}

sub foo (
    @meows where all-items(/meow/), # <-- use parens to avoid gobbling of params that follow
    @barks where all-items(/woof/) = ['woof'], # <-- or to add defaults
) {
    …
}

```

# DESCRIPTION

Type-constraining elements of list parameters, attributes, and subsets can be done with `where` clauses, however, they can quickly get overly complex when you want to constraint using multiple requirements. This module addresses that problem!

# EXPORTED SUBROUTINES

## sub all-items(+@matchers)

See SYNOPSIS for sample use.

Takes a list of matchers (anything that can be fed to [`.grep`](https://docs.raku.org/routine/grep). Returns a [`Callable`](https://docs.raku.org/type/Callable) that a `where` clause can use to check whether *all* items in a list match *all* of these matchers. Matchers will be checked in the order provided, short-circuiting as soon as a matcher fails. If an exception occurs during matching, it will be turned into a [`Failure`](https://docs.raku.org/type/Failure), gracefully failing the type check.

### Notes and tips

An empty list always matches the type constraint.

There's no thunking involved. `where all-items .so` is an error, as `.so` will be called on the list itself, not each of the elements and its return value will be used as a matcher. Use [`WhateverCode`](https://docs.raku.org/type/WhateverCode) instead: `where all-items *.so`.

All [`Seq`s](https://docs.raku.org/type/Seq) will be [cached](https://docs.raku.org/type/Seq).

Don't forget to add parens around the args when more params follow this routine (see `sub` example in SYNOPSIS).

Don't drink bleach.

# AUTHOR

Zoffix Znet

# COPYRIGHT AND LICENSE

Copyright 2015 - 2016 Zoffix Znet

Copyright 2017 - 2022 Raku Community

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


## dist_zef-Xliff-raku-RandomColor.md
# p6-RandomColor

A port of the RandomColor JavaScript library for Perl6.

# [Random Color](https://randomcolor.lllllllllllllllll.com)

A tiny script for generating attractive random colors.

## Options

You can pass an options object to influence the type of color it produces. The options object accepts the following properties:

`hue` – Controls the hue of the generated color. You can pass a string representing a color name: `red`, `orange`, `yellow`, `green`, `blue`, `purple`, `pink` and `monochrome` are currently supported. If you pass a hexidecimal color string such as `#00FFFF`, randomColor will extract its hue value and use that to generate colors.

`luminosity` – Controls the luminosity of the generated color. You can specify a string containing `bright`, `light` or `dark`.

`count` – An integer which specifies the number of colors to generate.

`seed` - An integer or string which when passed will cause randomColor to return the same color each time.

`format` – A string which specifies the format of the generated color. Possible values are `rgb`, `rgba`, `rgbArray`, `hsl`, `hsla`, `hslArray` and `hex` (default).

`alpha` – A decimal between 0 and 1. Only relevant when using a format with an alpha channel (`rgba` and `hsla`). Defaults to a random value.

## Examples

```

# Returns a hex code for an attractive color
RandomColor.new.list;

# Returns an array of ten green colors
RandomColor.new(
   count => 10,
   hue => 'green'
}).list;

# Returns a hex code for a light blue
RandomColor.new(
   luminosity => 'light',
   hue => 'blue'
).list;

# Returns a hex code for a 'truly random' color
RandomColor(
   luminosity => 'random',
   hue  => 'random'
).list;

# Returns a bright color in RGB
RandomColor.new(
   luminosity => 'bright',
   format => 'rgb' # e.g. 'rgb(225,200,20)'
).list;

# Returns a dark RGB color with random alpha
RandomColor.new(
   luminosity => 'dark',
   format => 'rgba' # e.g. 'rgba(9, 1, 107, 0.6482447960879654)'
});

# Returns a dark RGB color with specified alpha
RandomColor.new(
   luminosity => 'dark',
   format => 'rgba',
   alpha => 0.5 # e.g. 'rgba(9, 1, 107, 0.5)',
);

# Returns a light HSL color with random alpha
RandomColor.new(
   luminosity => 'light',
   format => 'hsla' # e.g. 'hsla(27, 88.99%, 81.83%, 0.6450211517512798)'
);

```

For more information, see the [homepage](https://randomcolor.lllllllllllllllll.com/)


## undeclared.md
class X::Undeclared

Compilation error due to an undeclared symbol

```raku
class X::Undeclared does X::Comp {}
```

Thrown when the compiler encounters a symbol that has not been declared, but needs to be.

Example

```raku
$x;

```

results in

｢text｣ without highlighting

```

```

===SORRY!===
Variable $x is not declared

```

```

# [Methods](#class_X::Undeclared "go to top of document")[§](#Methods "direct link")

## [method symbol](#class_X::Undeclared "go to top of document")[§](#method_symbol "direct link")

Returns the name of the undeclared symbol

## [method what](#class_X::Undeclared "go to top of document")[§](#method_what "direct link")

Returns the kind of symbol that was not declared (for example variable, type, routine).

Since The symbol wasn't declared, the compiler sometimes has to guess (or rather disambiguate) what kind of symbol it encounter that wasn't declared. For example if you write

```raku
say a;

```

Then the disambiguation defaults to reporting a missing subroutine, even though declaring a `constant a = 'a'` would also make the error go away.


## dist_zef-b7j0c-Net-IP-Parse.md
[![](https://img.shields.io/badge/License-BSD-yellow.svg)](https://opensource.org/licenses/BSD-2-Clause)
[![ci](https://github.com/bradclawsie/Net-IP-Parse/workflows/ci/badge.svg)](https://github.com/bradclawsie/Net-IP-Parse/actions)

# Net::IP::Parse

An IP type for Perl6.

## DESCRIPTION

This library tries to fill a gap of a standard type for IP addresses that can
be used in programs and other libraries. Preferrably Perl6 would ship with
a default implementation for this common type, but until then, this is one
attempt at defining such a type.

For our purposes, an IP address is an array of bytes. For IPv4, there
are four bytes. For IPv6, sixteen. Perl6 only provides a byte type
for native interfaces, and this doesn't have adequate degradation in case
of errors, so I have opted to use my own `Subsets::Common` which defines
a `UInt8` subset that integrates nicely for common use.

This library parses common formats for IP address and creates a `UInt8`
array of the right size that is well-formed. That means values that are
bytes (between 0 and 255). This means you may be able to create instances
that are syntactically correct but are not applicable to real use given
some point of IP specification. This library does not concern itself
with determining if you instantiate a reserved or otherwise practically
useless IP address, I leave this to you to determine.

There is also support for a CIDR type which lets you stipulate network
ranges.

The best set of examples for use can be found in the tests in `basic.t`
in the repository with this library.

IPv6 is complex. Please let me know what I have not properly supported.

## SYNOPSIS

```
use v6;
use Subsets::Common; # required
use Net::IP::Parse;

my IP $ipv4_from_str = IP.new(addr=><1.2.3.4>);
my IP $ipv4_from_octets = IP.new(octets=>Array[UInt8].new(1,2,3,4));
say 'equal' if ($ipv4_from_str ip== $ipv4_from_octets);

my IP $ipv6_from_str = IP.new(addr=>'dfea:dfea:dfea:dfea:dfea:dfea:dfea:dfea');
my IP $ipv6_from_octets = IP.new(octets=>Array[UInt8].new(223,234,223,234,223,234,223,234,223,234,223,234,223,234,223,234));
say 'equal' if ($ipv6_from_str ip== $ipv6_from_octets);

my IP $ip1 = IP.new(addr=><2001:db8:a0b:12f0::1:1>);
say 'equal' if ($ip1.str eq '2001:db8:a0b:12f0:0:0:1:1');
my IP $ip2 = IP.new(addr=><2001:db8:a0b:12f0:0:0:1:1>);
say 'equal' if ($ip ip1== $ip2);

my IP $ip3 = IP.new(addr=><1:0:0:0:1:0:0:1>);
my $compressed = $ip3.compress_str;
say 'equal' if ($compressed eq '1::1:0:0:1');

my CIDR $cidr_ipv4 = CIDR.new(cidr=>'8.8.8.8/16');
my IP $ip4 = IP.new(addr=>'8.8.0.1');
say 'in' if ($ip4 in_cidr $cidr_ipv4);

my CIDR $cidr_ipv6 = CIDR.new(cidr=>'2001:db8::/32');
my IP $ip5 = IP.new(addr=>'2001:0db8:0000:0000:0000:0000:0000:0001');
say 'in' if ($ip5 in_cidr $cidr_ipv6);

```

## AUTHOR

Brad Clawsie (PAUSE:bradclawsie, email:brad@b7j0c.org)

## LICENSE

This module is licensed under the BSD license, see: <https://b7j0c.org/stuff/license.txt>


## dist_zef-librasteve-Physics-Measure.md
[![](https://img.shields.io/badge/License-Artistic%202.0-0298c3.svg)](https://opensource.org/licenses/Artistic-2.0)
[![](https://github.com/librasteve/raku-Physics-Measure/actions/workflows/measure-weekly.yaml/badge.svg)](https://github.com/librasteve/raku-Physics-Measure/actions/workflows/measure-weekly.yaml)

# Version 2+

This version of Physics::Measure has been adapted to work with the new Physics::Unit:ver<2+>:api<2> release.

# raku-Physics-Measure

Provides Measure objects that have value, units and error and can be used in many common physics calculations. Uses [Physics::Unit](https://github.com/librasteve/raku-Physics-Unit) and [Physics::Error](https://github.com/librasteve/raku-Physics-Error).

# Instructions

`zef --verbose install Physics::Measure`

and, conversely, `zef uninstall Physics::Measure`

# Synopsis

```
use lib '../lib';
use Physics::Measure :ALL;

# Basic mechanics example (SI units)...

# Define a distance and a time
my \d = 42m;                say ~d;     #42 m      (Length)
my \t = 10s;                say ~t;     #10 s      (Time)

# Calculate speed and acceleration
my \u = d / t;              say ~u;     #4.2 m/s   (Speed)
my \a = u / t;              say ~a;     #0.42 m/s^2 (Acceleration)

# Define mass and calculate force
my \m = 25kg;               say ~m;     #25 kg     (Mass)
my \f = m * a;              say ~f;     #10.5 N    (Force)

# Calculate final speed and distance travelled
my \v = u + a*t;            say ~v;     #8.4 m/s   (Speed)
my \s = u*t + (1/2) * a * t*t;  say ~s; #63 m      (Length)

# Calculate potential energy
my \pe = f * s;             say ~pe;    #661.5 J   (Energy)

# Calculate kinetic energy
my \ke1 = (1/2) * m * u*u;
my \ke2 = (1/2) * m * v*v;

# Calculate the delta in kinetic energy
my \Δke = ke2 - ke1;

# Compare potential vs. delta kinetic energy
(pe cmp Δke).say;                      #Same

```

This example shows some key features of Physics::Measure...

* support for SI prefixes, base and derived units (cm, kg, ml and so on)
* imported as raku postfix operators for convenience and clarity
* custom math operators `(+-*/)` for easy inclusion in calculations
* inference of type class (Length, Time, Mass, etc.) from units
* derivation of type class of results (Speed, Acceleration, etc.)

# Use Cases

The Physics::Measure and Physics::Unit modules were designed with the following use cases in mind:

* convenient use for practical science - lab calculations and interactive presentation of data sets
* a framework for educators and students to interactively explore basic physics via a modern OO language
* an everyday unit conversion and calculation tool (not much point if it can't convert miles to km and so on)

Some other use cases - use for physical chemistry calculations (eg. environmental) and for historic data ingestion - have also been seen on the horizon and the author would be happy to work with you to help adapt to meet a wider set of needs.

# Design Model

To address the Use Cases, the following consistent functional parts have been created:

* a raku Class and Object model to represent Units and Measurements
* methods for Measure math operations, output, comparison, conversion, normalisation and rebasing
* a Unit Grammar to parse unit expressions and cope with textual variants such as ‘miles per hour’ or ‘mph’, or ‘m/s’, ‘ms^-1’, ‘m.s-1’
* an extensible library of about 800 built in unit types covering SI base, derived, US and imperial
* a set of "API" options to meet a variety of consumption needs

Together Physics::Measure and Physics::Unit follow this high level class design model:

```
class Unit {
   has Str $.defn;
   #...
}
class Measure {
   has Real $.value;
   has Unit $.units;
   has Error $.error;
   #...
}
class Length is Measure {}
class Time   is Measure {}
class Speed  is Measure {}
#and so on

```

Type classes represent physical measurement such as (Length), (Time), (Speed), etc. They are child classes of the (Measure) parent class.

You can do math operations on (Measure) objects - (Length) can add/subtract to (Length), (Time) can add/subtract to (Time), and so on. A mismatch like adding a (Length) to a (Time) gives a raku Type error *cannot convert in to different type Length*. You can, however, divide e.g. (Length) by (Time) and then get a (Speed) type back. (Length) \*\* 2 => (Area). (Length) \*\* 3 => (Volume). And so on. There are 36 pre-defined types provided. Methods are provided to create custom units and types.

Therefore, in the normal course, please make your objects as instances of the Child type classes.

# Three Consumer Options

## Option 1: Postfix Operator Syntax (SI Units)

As seen above, if you just want SI prefixes, base and derived units (cm, kg, ml and so on), the :ALL export label provides them as raku postfix:<> custom operators. This option is intended for scientist / coders who want fast and concise access to a modern Unit library. Here is another example, basic wave mechanics, bringing in the [Physics::Constants](https://github.com/librasteve/raku-Physics-Constants) module:

```
use Physics::Constants;  #<== must use before Physics::Measure
use Physics::Measure :ALL;

$Physics::Measure::round-to = 0.01;

my \λ = 2.5nm;
my \ν = c / λ;
my \Ep = ℎ * ν;

say "Wavelength of photon (λ) is " ~λ;              #2.5 nm
say "Frequency of photon (ν) is " ~ν.norm;          #119.92 petahertz
say "Energy of photon (Ep) is " ~Ep.norm;           #79.46 attojoule

```

The following SI units are provided in all Prefix-Unit combinations:

| SI Base Unit (7) | SI Derived Unit (20) | SI Prefix (20) |
| --- | --- | --- |
| 'm', 'metre', | 'Hz', 'hertz', | 'da', 'deka', |
| 'g', 'gram', | 'N', 'newton', | 'h', 'hecto', |
| 's', 'second', | 'Pa', 'pascal', | 'k', 'kilo', |
| 'A', 'amp', | 'J', 'joule', | 'M', 'mega', |
| 'K', 'kelvin', | 'W', 'watt', | 'G', 'giga', |
| 'mol', 'mol', | 'C', 'coulomb', | 'T', 'tera', |
| 'cd', 'candela', | 'V', 'volt', | 'P', 'peta', |
|  | 'F', 'farad', | 'E', 'exa', |
|  | 'Ω', 'ohm', | 'Z', 'zetta', |
|  | 'S', 'siemens', | 'Y', 'yotta', |
|  | 'Wb', 'weber', | 'd', 'deci', |
|  | 'T', 'tesla', | 'c', 'centi', |
|  | 'H', 'henry', | 'm', 'milli', |
|  | 'lm', 'lumen', | 'μ', 'micro', |
|  | 'lx', 'lux', | 'n', 'nano', |
|  | 'Bq', 'becquerel', | 'p', 'pico', |
|  | 'Gy', 'gray', | 'f', 'femto', |
|  | 'Sv', 'sievert', | 'a', 'atto', |
|  | 'kat', 'katal', | 'z', 'zepto', |
|  | 'l', 'litre', | 'y', 'yocto', |

#litre included due to common use of ml, dl, etc.

## Option 2: Object Constructor Syntax

In addition to the SI units listed above, Physics::Measure (and Physics::Unit) offers a comprehensive library of non-metric units. US units and Imperial units include feet, miles, knots, hours, chains, tons and over 200 more. The non-metric units are not exposed as postfix operators.

```
my Length $d = Length.new(value => 42, units => 'miles');   say ~$d;         #42 mile
my Time   $t = Time.new(  value =>  7, units => 'hours');   say ~$t;         #7 hr
my $s = $d / $t;                                  say ~$s.in('mph');         #6 mph

```

A flexible unit expression parser is included to cope with textual variants such as ‘miles per hour’ or ‘mph’; or ‘m/s’, ‘ms^-1’, ‘m.s-1’ (the SI derived unit representation) or ‘m⋅s⁻¹’ (the SI recommended string representation, with superscript powers). The unit expression parser decodes a valid unit string into its roots, extracting unit dimensions and inferring the appropriate type.

```
#Colloquial terms or unicode superscripts can be used for powers in unit declarations
    #square, sq, squared, cubic, cubed
    #x¹ x² x³ x⁴ and x⁻¹ x⁻² x⁻³ x⁻⁴

```

Of course, the standard raku object constructor syntax may be used for SI units too:

```
my Length $l = Length.new(value => 42, units => 'μm'); say ~$l; #42 micrometre

```

This syntax option is the most structured and raku native. For example, it helps educators to use units and basic physics exercises as a way to introduce students to formal raku Object Orientation principles.

## Option 3: Libra Shorthand Syntax

In many cases, coders will want the flexibility of the unit expression parser and the wider range of non-metric units but they also want a concise notation. In this case, the unicode libra emoji ♎ is provided as raku prefix for object construction. The subject can be enclosed in single quotes ♎'', double quotes ♎"" of (from v1.0.10) angle brackets ♎<>. Separate the number from the units with a space.

```
#The libra ♎ is shorthand to construct objects...
    my $a = ♎<4.3 m>;                  say "$a";		#4.3 m
    my $b = ♎<5e1 m>;                  say "$b";		#50 m
    my $c = $a;                          say "$c";		#4.3 m
    my Length $l = ♎ 42;                say "$l";		#42 m (default to base unit of Length)
#...there is an ASCII variant of <♎> namely <libra>

```

*Use the emoji editor provided on your system (or just cut and paste)*

```
#About 230 built in units are included, for example...
    my $v2 = ♎<7 yards^3>;          #7 yard^3         (Volume)
    my $v3 = $v2.in( 'm3' );        #5.352 m^3        (Volume)
    my $dsdt = $s / $t;             #0.000106438 m/s^2 (Acceleration)
    my $sm = ♎<70 mph>;             #70 mph           (Speed)
    my $fo = ♎<27 kg m / s2>;       #27 N             (Force)
    my $en = ♎<26 kg m^2 / s^2>;    #26 J             (Energy)
    my $po = ♎<25 kg m^2 / s^3>;    #25 W             (Power)

```

# Special Measure Types

## Angles

```
#Angles use degrees/minutes/seconds or decimal radians
    my $θ1 = ♎<45°30′30″>;      #45°30′30″ (using <> to deconfuse quotation marks)
    my $θ2 = ♎<2.141 radians>;  #'2.141 radian'
#NB. The unit name 'rad' is reserved for the unit of radioactive Dose

# Trigonometric functions sin, cos and tan (and arc-x) handle Angles
    my $sine = sin( $θ1 );      #0.7133523847299412
    my $arcsin = asin( $sine, units => '°' ); #45°30′30″
#NB. Provide the units => '°' tag to tell asin you want degrees back

```

## Time

```
#The Measure of Time has a raku Duration - i.e. the difference between two DateTime Instants:
    my $i1 = DateTime.now;
    my $i2 = DateTime.new( '2020-08-10T14:15:27.26Z' );
    my $i3 = DateTime.new( '2020-08-10T14:15:37.26Z' );
    my Duration $dur = $i3-$i2;

#Here's how to us the libra assignment operator ♎ for Time...
    my Time $t1 = ♎<5e1 s>';     	#50 s
    my Time $t2 = ♎ $dur;        	#10 s
    my $t3 = $t1 + $t2;         	#60 s
    my Time $t4 = ♎<2 hours>;   	#2 hr
    $dur = $t4.Duration;         #7200

```

# Unit Conversion

```
#Unit Conversion uses the .in() method - specify the new units as a String
    my Length $df = ♎<12.0 feet>;         #12 ft
    my $dm = $df.in( 'm' );               #3.658 m
       $dm = $df.in: <m>;                 #alternate form
    my Temperature $deg-c = ♎<39 °C>;
    my $deg-k = $deg-c.in( 'K' );         #312.15 K
    my $deg-cr = $deg-k.in( '°C' );       #39 °C

#Use arithmetic to get high order or inverse Unit types such as Area, Volume, Frequency, etc.
    my Area	      $x = $a * $a;           #18.49 m^2
    my Speed      $s = $a / $t2;          #0.43 m/s
    my Frequency  $f = 1  / $t2;          #0.1 Hz

#Use powers & roots with Int or Rat (<1/2>, <1/3> or <1/4>)
    my Volume     $v = $a ** 3;           #79.507 m^3
    my Length	   $d = $v ** <1/3>;       #0.43 m

```

The ① symbol is used to denote Dimensionless units.

# Rounding & Normalisation

```
#Set rounding precision (or reset with Nil) - does not reduce internal precision
    $Physics::Measure::round-to = 0.01;
#Normalize SI Units to the best SI prefix (from example above)
    say "Frequency of photon (ν) is " ~ν.norm;    #119.92 petahertz
#Reset to SI base type with the .rebase() method
    my $v4 = $v2.rebase;                  #5.35 m^3

```

# Thousand Separator | Euro Decimal

```
#Set behaviour if number part contains a comma ','
#use '' to allow as thousands sep / '.' to convert european style decimals
    $Physics::Measure::number-comma = '';
    my Speed $s2 = ♎'24,000 miles per hour'; #24000mph

```

# Comparison Methods

```
#Measures can be compared with $a cmp $b
    my $af = $a.in: 'feet';             #4.3 m => 14.108 feet
    say $af cmp $a;                     #Same
#Measures can be tested for equality with Numeric ==,!=
    say $af == $a;                      #True
    say $af != $a;                      #False
#Use string equality eq,ne to distinguish different units with same type
    say $af eq $a;                      #False
    say $af ne $a;                      #True

```

# Output Methods

To see what you have got, then go:

```
my $po = 25W;
say ~$po; say "$po"; say $po.Str;       #25 W  (defaults to derived unit)
say +$po; say $po.value; say $po.Real;  #25
say $po.^name;                          #(Power)
say $po.canonical;                      #25 m2.s-3.kg   (SI base units)
say $po.pretty;                         #25 m²⋅s⁻³⋅kg   (SI recommended style)
                                              ^...^......unicode Dot Operator U+22C5

```

# Dealing with Ambiguous Types

In a small number of case, the same units are used by different unit Types. Type hints
steer type inference:

```
has %.type-hint = %(
    Area           => <Area FuelConsumption>,
    Energy         => <Energy Torque>,
    Momentum       => <Momentum Impulse>,
    Frequency      => <Frequency Radioactivity>,
    SpecificEnergy => <SpecificEnergy Dose>,
);

```

To adjust this, you can delete the built in key and replace it with your own:

```
my %th := Unit.type-hint;

#default type-hints
my $en1 = ♎'60 J';     #'$en1 ~~ Energy';
my $tq1 = ♎'5 Nm';     #'$tq1 ~~ Torque';

#altered type-hints
%th<Energy>:delete;
%th<Torque> = <Energy Torque>;

my $fo3 = ♎'7.2 N';
my $le2 = ♎'2.2 m';
my $tq2 = $fo3 * $le2;  #'$tq2 ~~ Torque';

```

# Custom Measures

To make a custom Measure, you can use this incantation:

```
Measure.unit-find('nmile').type-bind('Reach');

class Reach is Measure {
    has $.units where *.name eq <nm nmile nmiles>.any;

    #| override .in to perform identity 1' (Latitude) == 1 nmile
    method in( Str $s where * eq <Latitude> ) {
        my $nv = $.value / 60;
        Latitude.new( value => $nv, compass => <N> )
    }
}

```

# Summary

The family of Physics::Measure, Physics::Unit and Physics::Constants raku modules is a consistent and extensible toolkit intended for science and education. It provides a comprehensive library of both metric (SI) and non-metric units, it is built on a Type Object foundation, it has a unit expression Grammar and implements math, conversion and comparison methods.

Any feedback is welcome to librasteve / via the github Issues above.

Copyright (c) Henley Cloud Consulting Ltd. 2021-2023