## dist_zef-jonathanstowe-Pg-Notify.md
# PG::Notify

Raku interface to PostgresQL notifies.

![Build Status](https://github.com/jonathanstowe/Pg-Notify/workflows/CI/badge.svg)

## Synopsis

```

use Pg::Notify;
use DBIish;

my $db = DBIish.connect('Pg', database => "dbdishtest");
my $channel = "test";

my $notify = Pg::Notify.new(:$db, :$channel );

react {
    whenever $notify -> $notification {
        say $notification.extra;
    }
	# Provide a notification
	whenever Supply.interval(1) -> $v {
		$db.do("NOTIFY $channel, '$v'");
	}
}

```

## Description

This provides a simple mechanism to get a supply of the PostgresQL
notifications for a particular *channel*. The supply will emit a stream
of `pg-notify` objects corresponding to a `NOTIFY` executed on
the connected Postgres database.

Typically the `NOTIFY` will be invoked in a trigger or other server
side code but could just as easily be in some other user code (as in
the Synopsis above,)

The objects of type `Pg::Notify` have a `Supply` method that
allows coercion in places that expect a Supply (such as `whenever`
in the Synopsis above.) but you can this Supply directly if you want to
`tap` it for instance.

## Install

This relies on [DBIish](https://github.com/raku-community-modules/DBIish) and ideally
you will have a working PostgreSQL database connection for the user that you will run the tests as.

For the tests you can control how it connects to the database with the
environment variables:

* $PG\_NOTIFY\_DB - the name of the database you want to use, otherwise `dbdishtest`
* $PG\_NOTIFY\_USER - the username to be used, (otherwise will connect as the current user,)
* $PG\_NOTIFY\_PW - the password to be used, (otherwise no password will be used.)
* $PG\_NOTIFY\_HOST - the host to which the DB connection will made, the default is to connect to a local PG server.

These should be set before the tests (or install,) are run.

Assuming you have a working Rakudo installation you should just be able to use *zef* :

```
zef install Pg::Notify

# or from a local copy

zef install .

```

But I can't think there should be any problem with any installer that may come along in the future.

## Support

This relies on the `poll` C library function, on Linux this is part
of the runtime library that is always loaded but it might not be on other
operating systems, if you have one of those systems I'd be grateful for
a patch to make it work there.

If you have any other suggestions or problems please report at
<https://github.com/jonathanstowe/Pg-Notify/issues>

## Copyright and Licence

This is free software, please see the <LICENCE> file in the distribution.

© Jonathan Stowe 2017 - 2021


## dist_cpan-FCO-Cro-HTTP-Session-Red.md
[![Build Status](https://travis-ci.org/FCO/Cro-HTTP-Session-Red.svg?branch=master)](https://travis-ci.org/FCO/Cro-HTTP-Session-Red)

# NAME

Cro::HTTP::Session::Red - Plugin for Cro to use Red as session manager

# SYNOPSIS

```
# service.pl

use Cro::HTTP::Log::File;
use Cro::HTTP::Server;
use Routes;
use Red;

$GLOBAL::RED-DB = database "SQLite", :database("{%*ENV<HOME>}/test.db");
$GLOBAL::RED-DEBUG = so %*ENV<RED_DEBUG>;

User.^create-table: :if-not-exists;
UserSession.^create-table: :if-not-exists;

try User.^create: :name<CookieMonster>, :email<cookie@monster.com>, :password("1234");

my Cro::Service $http = Cro::HTTP::Server.new(
    http => <1.1>,
    host => %*ENV<CLASSIFIED_HOST> ||
        die("Missing CLASSIFIED_HOST in environment"),
    port => %*ENV<CLASSIFIED_PORT> ||
        die("Missing CLASSIFIED_PORT in environment"),
    application => routes(),
    after => [
        Cro::HTTP::Log::File.new(logs => $*OUT, errors => $*ERR)
    ]
);
$http.start;
say "Listening at http://%*ENV<CLASSIFIED_HOST>:%*ENV<CLASSIFIED_PORT>";
react {
    whenever signal(SIGINT) {
        say "Shutting down...";
        $http.stop;
        done;
    }
}

# lib/Routes.pm6

use Cro::HTTP::Router;
use Cro::HTTP::Session::Red;
use Red;

model UserSession { ... }

model User is table<account> {
    has UInt            $!id       is serial;
    has Str             $.name     is column;
    has Str             $.email    is column{ :unique };
    has Str             $.password is column;
    has UserSession     @.sessions is relationship{ .uid }

    method check-password($password) {
        $password eq $!password
    }
}

model UserSession is table<logged_user> does Cro::HTTP::Auth {
    has Str  $.id         is id;
    has UInt $.uid        is referencing{ User.id };
    has User $.user       is relationship{ .uid } is rw;
}

sub routes() is export {
    route {
        before Cro::HTTP::Session::Red[UserSession].new: cookie-name => 'MY_SESSION_COOKIE_NAME';
        get -> UserSession $session (User :$user, |) {
            content 'text/html', "<h1> Logged User: $user.name() </h1>";
        }

        get -> 'login' {
            content 'text/html', q:to/HTML/;
                <form method="POST" action="/login">
                    <div>
                        Username: <input type="text" name="email" />
                    </div>
                    <div>
                        Password: <input type="password" name="password" />
                    </div>
                    <input type="submit" value="Log In" />
                </form>
            HTML
        }

        post -> UserSession $session, 'login' {
            request-body -> (Str() :$email, Str() :$password, *%) {
                my $user = User.^load: :$email;
                if $user.?check-password: $password {
                    $session.user = $user;
                    $session.^save;
                    redirect '/', :see-other;
                }
                else {
                    content 'text/html', "Bad username/password";
                }
            }
        }
    }
}

```

# DESCRIPTION

Cro::HTTP::Session::Red is a Plugin for Cro to use Red as session manager. You can create any custom Red model to store the Cro session, but its id must be a Str and the generated session string will be used as the id.

# AUTHOR

Fernando Correa de Oliveira [fernandocorrea@gmail.com](mailto:fernandocorrea@gmail.com)

# COPYRIGHT AND LICENSE

Copyright 2019 Fernando Correa de Oliveira

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


## embedded.md
class X::Syntax::Comment::Embedded

Compilation error due to a malformed inline comment

```raku
class X::Syntax::Comment::Embedded does X::Syntax { }
```

Syntax error thrown when `#`` is encountered and it is not followed by an opening curly brace.

For example

```raku
#`

```

dies with

｢text｣ without highlighting

```

```

===SORRY!===
Opening bracket is required for #` comment

```

```


## packagehow.md
class Metamodel::PackageHOW

Metaobject representing a Raku package.

```raku
class Metamodel::PackageHOW
  does Metamodel::Naming
  does Metamodel::Documenting
  does Metamodel::Stashing
  does Metamodel::TypePretense
  does Metamodel::MethodDelegation { }
```

*Warning*: this class is part of the Rakudo implementation, and is not a part of the language specification.

`Metamodel::PackageHOW` is the metaclass behind the `package` keyword.

```raku
package P {};
say P.HOW; # OUTPUT: «Perl6::Metamodel::PackageHOW.new␤»
```

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

## [method archetypes](#class_Metamodel::PackageHOW "go to top of document")[§](#method_archetypes "direct link")

```raku
method archetypes()
```

Returns the archetypes for this model, that is, the properties a metatype can implement.

## [method new](#class_Metamodel::PackageHOW "go to top of document")[§](#method_new "direct link")

```raku
method new(*%named)
```

Creates a new `PackageHOW`.

## [method new\_type](#class_Metamodel::PackageHOW "go to top of document")[§](#method_new_type "direct link")

```raku
method new_type(:$name = '<anon>', :$repr, :$ver, :$auth)
```

Creates a new package, with optional representation, version and auth field.

## [compose](#class_Metamodel::PackageHOW "go to top of document")[§](#compose "direct link")

```raku
method compose($obj, :$compiler_services)
```

Sets the metapackage as composed.

## [is\_composed](#class_Metamodel::PackageHOW "go to top of document")[§](#is_composed "direct link")

```raku
method is_composed($obj)
```

Returns the composed status of the metapackage.


## fallback.md
FALLBACK

Combined from primary sources listed below.

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

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

```raku
method FALLBACK(| --> Nil) {}
```

The [fallback method](/language/typesystem#index-entry-FALLBACK_(method)) takes any arguments and always returns a `Nil`.


## invalidformat.md
class X::Temporal::InvalidFormat

Error due to using an invalid format when creating a DateTime or Date

```raku
class X::Temporal::InvalidFormat does X::Temporal is Exception { }

```

This exception is thrown when code tries to create a [`DateTime`](/type/DateTime) or [`Date`](/type/Date) object using an invalid format.

```raku
my $dt = Date.new("12/25/2015");
CATCH { default { put .^name, ': ', .Str } };
# OUTPUT: «X::Temporal::InvalidFormat: Invalid Date string '12/25/2015'; use yyyy-mm-dd instead␤»

```

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

## [method invalid-str](#class_X::Temporal::InvalidFormat "go to top of document")[§](#method_invalid-str "direct link")

Returns the invalid format string (`12/25/2015` in the example above)

## [method target](#class_X::Temporal::InvalidFormat "go to top of document")[§](#method_target "direct link")

Returns the target type ([`Date`](/type/Date) in the example above)

## [method format](#class_X::Temporal::InvalidFormat "go to top of document")[§](#method_format "direct link")

Returns valid format strings for the target type in question, (`yyyy-mm-dd` in the example above)


## dist_zef-FRITH-Math-Libgsl-Statistics.md
[![Actions Status](https://github.com/frithnanth/raku-Math-Libgsl-Statistics/workflows/test/badge.svg)](https://github.com/frithnanth/raku-Math-Libgsl-Statistics/actions)

# NAME

Math::Libgsl::Statistics - An interface to libgsl, the Gnu Scientific Library - Statistics

# SYNOPSIS

```
use Math::Libgsl::Statistics;

my @data = ^10;
say "mean = { mean(@data) }, variance = { variance(@data) }";

```

# DESCRIPTION

Math::Libgsl::Statistics is an interface to the Statistics functions of libgsl, the Gnu Scientific Library.

The functions in this module come in 10 data types:

* Math::Libgsl::Statistics (default: num64)
* Math::Libgsl::Statistics::Num32
* Math::Libgsl::Statistics::Int8
* Math::Libgsl::Statistics::Int16
* Math::Libgsl::Statistics::Int32
* Math::Libgsl::Statistics::Int64
* Math::Libgsl::Statistics::UInt8
* Math::Libgsl::Statistics::UInt16
* Math::Libgsl::Statistics::UInt32
* Math::Libgsl::Statistics::UInt64

All the following functions are available in the modules correspondiing to each datatype, except where noted.

### mean(@data!, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function returns the arithmetic mean of @data.

### variance(@data!, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function returns the estimated variance of @data. This function computes the mean, if you already computed the mean, use the next function.

### variance-m(@data!, Num() $mean!, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride)

This function returns the sample variance of @data relative to the given value of $mean.

### sd(@data!, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function returns the estimated standard deviation of @data.

### sd-m(@data!, Num() $mean!, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function returns the sample standard deviation of @data relative to the given value of $mean.

### tss(@data!, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

These functions return the total sum of squares (TSS) of @data.

### tss-m(@data!, Num() $mean!, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

These functions return the total sum of squares (TSS) of @data relative to the given value of $mean.

### variance-with-fixed-mean(@data!, Num() $mean!, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function computes an unbiased estimate of the variance of @data when the population mean $mean of the underlying distribution is known a priori.

### sd-with-fixed-mean(@data!, Num() $mean!, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function calculates the standard deviation of @data for a fixed population mean $mean.

### absdev(@data!, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function computes the absolute deviation from the mean of @data.

### absdev-m(@data!, Num() $mean!, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function computes the absolute deviation of the dataset @data relative to the given value of $mean.

### skew(@data!, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function computes the skewness of @data.

### skew-m-sd(@data!, Num() $mean!, Num() $sd!, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function computes the skewness of the dataset @data using the given values of the mean $mean and standard deviation $sd,

### kurtosis(@data!, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function computes the kurtosis of @data.

### kurtosis-m-sd(@data!, Num() $mean!, Num() $sd!, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function computes the kurtosis of the dataset @data using the given values of the mean $mean and standard deviation $sd,

### autocorrelation(@data!, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function computes the lag-1 autocorrelation of the dataset @data.

### autocorrelation-m(@data!, Num() $mean!, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function computes the lag-1 autocorrelation of the dataset @data using the given value of the mean $mean.

### covariance(@data1!, @data2! where \*.elems == @data1.elems, Int() :$stride1? = 1, Int() :$stride2? = 1, Int() :$n? = (@data1.elems / $stride1).Int --> Num)

This function computes the covariance of the datasets @data1 and @data2.

### covariance-m(@data1!, @data2! where \*.elems == @data1.elems, Num() $mean1!, Num() $mean2!, Int() :$stride1? = 1, Int() :$stride2? = 1, Int() :$n? = (@data1.elems / $stride1).Int --> Num)

This function computes the covariance of the datasets @data1 and @data2 using the given values of the means, $mean1 and $mean2.

### correlation(@data1!, @data2! where \*.elems == @data1.elems, Int() :$stride1? = 1, Int() :$stride2? = 1, Int() :$n? = (@data1.elems / $stride1).Int --> Num)

This function efficiently computes the Pearson correlation coefficient between the datasets @data1 and @data2.

### spearman(@data1!, @data2! where \*.elems == @data1.elems, Int() :$stride1? = 1, Int() :$stride2? = 1, Int() :$n? = (@data1.elems / $stride1).Int --> Num)

This function computes the Spearman rank correlation coefficient between the datasets @data1 and @data2.

### wmean(@w!, @data!, Int() :$wstride? = 1, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function returns the weighted mean of the dataset @data using the set of weights @w. This function is available only for Numeric types, so only when using Math::Libgsl::Statistics or Math::Libgsl::Statistics::Num32.

### wvariance(@w!, @data!, Int() :$wstride? = 1, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function returns the estimated variance of the dataset @data using the set of weights @w. This function is available only for Numeric types, so only when using Math::Libgsl::Statistics or Math::Libgsl::Statistics::Num32.

### wvariance-m(@w!, @data!, Num() $wmean!, Int() :$wstride? = 1, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function returns the estimated variance of the weighted dataset @data using the given weighted mean $wmean. This function is available only for Numeric types, so only when using Math::Libgsl::Statistics or Math::Libgsl::Statistics::Num32.

### wsd(@w!, @data!, Int() :$wstride? = 1, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function returns the standard deviation of the weighted dataset @data. This function is available only for Numeric types, so only when using Math::Libgsl::Statistics or Math::Libgsl::Statistics::Num32.

### wsd-m(@w!, @data!, Num() $wmean!, Int() :$wstride? = 1, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function returns the standard deviation of the weighted dataset @data using the given weighted mean $wmean. This function is available only for Numeric types, so only when using Math::Libgsl::Statistics or Math::Libgsl::Statistics::Num32.

### wvariance-with-fixed-mean(@w!, @data!, Num() $mean!, Int() :$wstride? = 1, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function computes an unbiased estimate of the variance of the weighted dataset @data when the population mean $mean of the underlying distribution is known a priori. This function is available only for Numeric types, so only when using Math::Libgsl::Statistics or Math::Libgsl::Statistics::Num32.

### wsd-with-fixed-mean(@w!, @data!, Num() $mean!, Int() :$wstride? = 1, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function computes an unbiased estimate of the standard deviation of the weighted dataset @data when the population mean $mean of the underlying distribution is known a priori. This function is available only for Numeric types, so only when using Math::Libgsl::Statistics or Math::Libgsl::Statistics::Num32.

### wtss(@w!, @data!, Int() :$wstride? = 1, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

These functions return the weighted total sum of squares (TSS) of @data. This function is available only for Numeric types, so only when using Math::Libgsl::Statistics or Math::Libgsl::Statistics::Num32.

### wtss-m(@w!, @data!, Num() $wmean!, Int() :$wstride? = 1, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

These functions return the weighted total sum of squares (TSS) of @data when the population mean $mean of the underlying distribution is known a priori. This function is available only for Numeric types, so only when using Math::Libgsl::Statistics or Math::Libgsl::Statistics::Num32.

### wabsdev(@w!, @data!, Int() :$wstride? = 1, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function computes the weighted absolute deviation from the weighted mean of @data. This function is available only for Numeric types, so only when using Math::Libgsl::Statistics or Math::Libgsl::Statistics::Num32.

### wabsdev-m(@w!, @data!, Num() $wmean!, Int() :$wstride? = 1, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function computes the absolute deviation of the weighted dataset @data about the given weighted mean $wmean. This function is available only for Numeric types, so only when using Math::Libgsl::Statistics or Math::Libgsl::Statistics::Num32.

### wskew(@w!, @data!, Int() :$wstride? = 1, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function computes the weighted skewness of the dataset @data. This function is available only for Numeric types, so only when using Math::Libgsl::Statistics or Math::Libgsl::Statistics::Num32.

### wskew-m-sd(@w!, @data!, Num() $wmean!, Num() $wsd!, Int() :$wstride? = 1, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function computes the weighted skewness of the dataset @data using the given values of the weighted mean and weighted standard deviation, $wmean and $wsd. This function is available only for Numeric types, so only when using Math::Libgsl::Statistics or Math::Libgsl::Statistics::Num32.

### wkurtosis(@w!, @data!, Int() :$wstride? = 1, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function computes the weighted kurtosis of the dataset @data. This function is available only for Numeric types, so only when using Math::Libgsl::Statistics or Math::Libgsl::Statistics::Num32.

### wkurtosis-m-sd(@w!, @data!, Num() $wmean!, Num() $wsd!, Int() :$wstride? = 1, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function computes the weighted kurtosis of the dataset @data using the given values of the weighted mean and weighted standard deviation, $wmean and $wsd. This function is available only for Numeric types, so only when using Math::Libgsl::Statistics or Math::Libgsl::Statistics::Num32.

### smax(@data!, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function returns the maximum value in @data.

### smin(@data!, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function returns the minimum value in @data.

### sminmax(@data!, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> List)

This function returns both the minimum and maximum values in @data in a single pass.

### smax-index(@data!, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Int)

This function returns the index of the maximum value in @data.

### smin-index(@data!, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Int)

This function returns the index of the minimum value in @data.

### sminmax-index(@data!, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> List)

This function returns the indexes of the minimum and maximum values in @data in a single pass.

### median-from-sorted-data(@sorted-data! where { [<] @sorted-data }, Int() :$stride? = 1, Int() :$n? = (@sorted-data.elems / $stride).Int --> Num)

This function returns the median value of @sorted-data.

### median(@data!, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function returns the median value of @data.

### quantile-from-sorted-data(@sorted-data! where { [<] @sorted-data }, Num() $percentile!, Int() :$stride? = 1, Int() :$n? = (@sorted-data.elems / $stride).Int --> Num)

This function returns a quantile value of @sorted-data. The quantile is determined by the $percentile, a fraction between 0 and 1. For example, to compute the value of the 75th percentile $percentile should have the value 0.75.

### select(@data!, Int() $k, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

This function finds the k-th smallest element of the input array @data.

### trmean-from-sorted-data(Num() $alpha, @sorted-data! where { [<] @sorted-data }, Int() :$stride? = 1, Int() :$n? = (@sorted-data.elems / $stride).Int --> Num)

This function returns the trimmed mean of @sorted-data.

### gastwirth-from-sorted-data(@sorted-data! where { [<] @sorted-data }, Int() :$stride? = 1, Int() :$n? = (@sorted-data.elems / $stride).Int --> Num)

This function returns the Gastwirth location estimator of @sorted-data.

### mad0(@data!, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

### mad(@data!, Int() :$stride? = 1, Int() :$n? = (@data.elems / $stride).Int --> Num)

These functions return the median absolute deviation of @data. The mad0 function calculates the MAD statistic without the bias correction scale factor.

### Sn0-from-sorted-data(@sorted-data! where { [<] @sorted-data }, Int() :$stride? = 1, Int() :$n? = (@sorted-data.elems / $stride).Int --> Num)

### Sn-from-sorted-data(@sorted-data! where { [<] @sorted-data }, Int() :$stride? = 1, Int() :$n? = (@sorted-data.elems / $stride).Int --> Num)

These functions return the Sₙ statistic of @sorted-data. The Sn0 function calculates the Sₙ statistic without the bias correction scale factors.

### Qn0-from-sorted-data(@sorted-data! where { [<] @sorted-data }, Int() :$stride? = 1, Int() :$n? = (@sorted-data.elems / $stride).Int --> Num)

### Qn-from-sorted-data(@sorted-data! where { [<] @sorted-data }, Int() :$stride? = 1, Int() :$n? = (@sorted-data.elems / $stride).Int --> Num)

These functions return the Qₙ statistic of @sorted-data. The Qn0 function calculates the Qₙ statistic without the bias correction scale factors.

# C Library Documentation

For more details on libgsl see <https://www.gnu.org/software/gsl/>. The excellent C Library manual is available here <https://www.gnu.org/software/gsl/doc/html/index.html>, or here <https://www.gnu.org/software/gsl/doc/latex/gsl-ref.pdf> in PDF format.

# Prerequisites

This module requires the libgsl library to be installed. Please follow the instructions below based on your platform:

## Debian Linux and Ubuntu 20.04+

```
sudo apt install libgsl23 libgsl-dev libgslcblas0

```

That command will install libgslcblas0 as well, since it's used by the GSL.

## Ubuntu 18.04

libgsl23 and libgslcblas0 have a missing symbol on Ubuntu 18.04. I solved the issue installing the Debian Buster version of those three libraries:

* <http://http.us.debian.org/debian/pool/main/g/gsl/libgslcblas0_2.5+dfsg-6_amd64.deb>
* <http://http.us.debian.org/debian/pool/main/g/gsl/libgsl23_2.5+dfsg-6_amd64.deb>
* <http://http.us.debian.org/debian/pool/main/g/gsl/libgsl-dev_2.5+dfsg-6_amd64.deb>

# Installation

To install it using zef (a module management tool):

```
$ zef install Math::Libgsl::Statistics

```

# AUTHOR

Fernando Santagata [nando.santagata@gmail.com](mailto:nando.santagata@gmail.com)

# COPYRIGHT AND LICENSE

Copyright 2020 Fernando Santagata

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


## ratstr.md
class RatStr

Dual value rational number and string

```raku
class RatStr is Allomorph is Rat {}
```

`RatStr` is a dual value type, a subclass of both [`Allomorph`](/type/Allomorph), hence [`Str`](/type/Str), and [`Rat`](/type/Rat).

See [`Allomorph`](/type/Allomorph) for further details.

```raku
my $rat-str = <42.1>;
say $rat-str.^name;       # OUTPUT: «RatStr␤»

my Rat $rat = $rat-str;   # OK!
my Str $str = $rat-str;   # OK!

# ∈ operator cares about object identity
say 42.1 ∈ <42.1  55  1>; # OUTPUT: «False␤»

```

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

## [method new](#class_RatStr "go to top of document")[§](#method_new "direct link")

```raku
method new(Rat $i, Str $s)
```

The constructor requires both the [`Rat`](/type/Rat) and the [`Str`](/type/Str) value, when constructing one directly the values can be whatever is required:

```raku
my $f = RatStr.new(42.1, "forty two and a bit");
say +$f; # OUTPUT: «42.1␤»
say ~$f; # OUTPUT: «"forty two and a bit"␤»
```

## [method Capture](#class_RatStr "go to top of document")[§](#method_Capture "direct link")

```raku
method Capture(RatStr:D: --> Capture:D)
```

Equivalent to [`Mu.Capture`](/type/Mu#method_Capture).

## [method Numeric](#class_RatStr "go to top of document")[§](#method_Numeric "direct link")

```raku
multi method Numeric(RatStr:D: --> Rat:D)
multi method Numeric(RatStr:U: --> Rat:D)
```

The `:D` variant returns the numeric portion of the invocant. The `:U` variant issues a warning about using an uninitialized value in numeric context and then returns value `0.0`.

## [method Rat](#class_RatStr "go to top of document")[§](#method_Rat "direct link")

```raku
method Rat
```

Returns the [`Rat`](/type/Rat) value of the `RatStr`.

## [method Real](#class_RatStr "go to top of document")[§](#method_Real "direct link")

```raku
multi method Real(Real:D: --> Rat:D)
multi method Real(Real:U: --> Rat:D)
```

The `:D` variant returns the numeric portion of the invocant. The `:U` variant issues a warning about using an uninitialized value in numeric context and then returns value `0.0`.

# [Operators](#class_RatStr "go to top of document")[§](#Operators "direct link")

## [infix `===`](#class_RatStr "go to top of document")[§](#infix_=== "direct link")

```raku
multi infix:<===>(RatStr:D $a, RatStr:D $b)
```

`RatStr` Value identity operator. Returns `True` if the [`Rat`](/type/Rat) values of `$a` and `$b` are [identical](/routine/===) and their [`Str`](/type/Str) values are also [identical](/routine/===). Returns `False` otherwise.

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

Type relations for `RatStr`

raku-type-graph

RatStr
RatStr

Allomorph
Allomorph

RatStr->Allomorph

Rat
Rat

RatStr->Rat

Mu
Mu

Any
Any

Any->Mu

Cool
Cool

Cool->Any

Stringy
Stringy

Str
Str

Str->Cool

Str->Stringy

Allomorph->Str

Numeric
Numeric

Real
Real

Real->Numeric

Rational
Rational

Rational->Real

Rat->Cool

Rat->Rational

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


## dist_github-FCO-Test-Time.md
[![Build Status](https://travis-ci.org/FCO/test-time.svg?branch=master)](https://travis-ci.org/FCO/test-time)

# Test::Time

Use **Test::Scheduler** to use on your tests, not only Promises, but **sleep**, **now** and time.

```
    my $started = now;
    $*SCHEDULER = mock-time :auto-advance;

    sleep 10;
    say "did it passed { now - $started } seconds?";
    unmock-time;

    say "No, just passed { now - $started } seconds!";

    #`{{{
    Output:
        did it passed 10.0016178 seconds?
        No, just passed 0.07388266 seconds!
    }}}

```

Or you can use `$*SCHEDULER.advance-by: 10` as you would when using **Test::Scheduler**


## dist_github-skinkade-Crypt-Bcrypt.md
# Crypt::Bcrypt

[![Build Status](https://travis-ci.org/skinkade/p6-Crypt-Bcrypt.svg?branch=master)](https://travis-ci.org/skinkade/p6-Crypt-Bcrypt)

Easy `bcrypt` password hashing in Perl6.

## Synopsis

Password hashing and verification are one function each, and utilize a
crypt()-style output string:

```
> use Crypt::Bcrypt;

> my $hash = bcrypt-hash("password")
$2b$12$EFUDTFQAf/6YwmnN/FKyX.kH0BsE/YNExuIQcI1WZXO/rwkmD8G2S

> bcrypt-match("password", $hash)
True

> bcrypt-match("wrong", $hash)
False

> bcrypt-hash("password", :rounds(15))
$2b$15$BcxIqbIcb1bDt3SHkEjO/ePcdeNV8f2xeFSQTyoiidYGUA03lptrm

```

## Credit

This module uses the Openwall crypt\_blowfish library by Solar Designer. See <http://www.openwall.com/crypt/> and the header of
[crypt\_blowfish.c](ext/crypt_blowfish-1.3/crypt_blowfish.c) for details.

## License

The Openwall library is licensed and redistributed under the terms outlined in the header of [crypt\_blowfish.c](ext/crypt_blowfish-1.3/crypt_blowfish.c). Any modifications are released under the same terms.

This module is released under the terms of the ISC License.
See the <LICENSE> file for details.


## dist_github-mj41-SP6.md
# SP6 - Simple Raku templates

## Examples

```
> cat t/templ/base.sp6 ; echo
foobar
> raku -Ilib bin/sp6 --templ_dir=t/templ -e='aa {include "base.sp6"} bb'
aa foobar bb

> cat t/templ/inside-outher.sp6  ; echo
outherA {main_part} outherB
> raku -Ilib bin/sp6 --templ_dir=t/templ -e='aa {include "base.sp6"} bb' --inside=inside-outher.sp6
outherA aa foobar bb outherB

raku -Ilib bin/sp6 --templ_dir=../BrnoPM-Web/templ/ --templ=index.sp6 --inside=inc/html.sp6

```

## How it works

```
> raku -Ilib bin/sp6 --templ_dir=t/templ --debug include.sp6
Template fpath: 't/templ/include.sp6'
code: "Qc ｢aa \{include 'inc/include-inner.sp6'} cc｣;"
Template fpath: 't/templ/inc/include-inner.sp6'
code: "Qc ｢inner-text｣;"
output:
aa inner-text cc

```

## Know issues

Characters '｢' and '｣' are forbidden.


## sibling.md
sibling

Combined from primary sources listed below.

# [In IO::Path](#___top "go to top of document")[§](#(IO::Path)_method_sibling "direct link")

See primary documentation
[in context](/type/IO/Path#method_sibling)
for **method sibling**.

```raku
method sibling(IO::Path:D: Str() $sibling --> IO::Path:D)
```

Allows to reference a sibling file or directory. Returns a new `IO::Path` based on the invocant, with the [`.basename`](/type/IO/Path#method_basename) changed to `$sibling`. The `$sibling` is allowed to be a multi-part path fragment; see also [`.add`](/type/IO/Path#method_add).

```raku
say '.bashrc'.IO.sibling: '.bash_aliases'; # OUTPUT: «.bash_aliases".IO␤»
say '/home/camelia/.bashrc'.IO.sibling: '.bash_aliases';
# OUTPUT: «/home/camelia/.bash_aliases".IO␤»

say '/foo/' .IO.sibling: 'bar';  # OUTPUT: «/bar".IO␤»
say '/foo/.'.IO.sibling: 'bar';  # OUTPUT: «/foo/bar".IO␤»
```


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

# NAME

OO::Monitors - Objects with mutual exclusion and condition variables

# SYNOPSIS

```
use OO::Monitors;

monitor Foo {
    has $.bar

    # accessible by one thread at a time
    method frobnicate() { }
}

```

# DESCRIPTION

A monitor provides per-instance mutual exclusion for objects. This means that for a given object instance, only one thread can ever be inside its methods at a time. This is achieved by a lock being associated with each object. The lock is acquired automatically at the entry to each method in the monitor. Condition variables are also supported.

## Basic Usage

A monitor looks like a normal class, but declared with the `monitor` keyword.

```
use OO::Monitors;

monitor IPFilter {
    has %!active;
    has %!blacklist;
    has $.limit = 10;
    has $.blocked = 0;

    method should-start-request($ip) {
        if %!blacklist{$ip}
          || (%!active{$ip} // 0) == $.limit {
            $!blocked++;
            return False;
        }
        else {
            %!active{$ip}++;
            return True;
        }
    }

    method end-request($ip) {
        %!active{$ip}--;
    }
}

```

That's about all there is to it. The monitor meta-object enforces mutual exclusion.

## Circular waiting

Monitors are vulnerable to deadlock, if you set up a circular dependency. Keep object graphs involving monitors simple and cycle-free, so far as is possible.

# AUTHOR

Jonathan Worthington

Source can be located at: <https://github.com/raku-community-modules/OO-Monitors> . Comments and Pull Requests are welcome.

# COPYRIGHT AND LICENSE

Copyright 2014 - 2021 Jonathan Worthington

Copyright 2024, 2025 Raku Community

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


## dist_zef-FRITH-Math-Libgsl-Matrix.md
## Chunk 1 of 2
[![Actions Status](https://github.com/frithnanth/raku-Math-Libgsl-Matrix/workflows/test/badge.svg)](https://github.com/frithnanth/raku-Math-Libgsl-Matrix/actions)

# NAME

Math::Libgsl::Matrix Math::Libgsl::Vector - An interface to libgsl, the Gnu Scientific Library - Vector and matrix algebra.

# SYNOPSIS

```
use Math::Libgsl::Vector;
use Math::Libgsl::Matrix;

```

# DESCRIPTION

Math::Libgsl::Matrix provides an interface to the vector and matrix algebra functions of libgsl - the GNU Scientific Library.

This package provides both the low-level interface to the C library (Raw) and a more comfortable interface layer for the Raku programmer.

This module comes with two classes, Vector and Matrix, available in 12 data types, so it offers 24 classes:

* Math::Libgsl::Vector - default, corresponding to a Math::Libgsl::Vector::Num64
* Math::Libgsl::Vector::Num32
* Math::Libgsl::Vector::Int32
* Math::Libgsl::Vector::UInt32
* Math::Libgsl::Vector::Int64
* Math::Libgsl::Vector::UInt64
* Math::Libgsl::Vector::Int16
* Math::Libgsl::Vector::UInt16
* Math::Libgsl::Vector::Int8
* Math::Libgsl::Vector::UInt8
* Math::Libgsl::Vector::Complex32
* Math::Libgsl::Vector::Complex64
* Math::Libgsl::Matrix - default, corresponding to a Math::Libgsl::Matrix::Num64
* Math::Libgsl::Matrix::Num32
* Math::Libgsl::Matrix::Int32
* Math::Libgsl::Matrix::UInt32
* Math::Libgsl::Matrix::Int64
* Math::Libgsl::Matrix::UInt64
* Math::Libgsl::Matrix::Int16
* Math::Libgsl::Matrix::UInt16
* Math::Libgsl::Matrix::Int8
* Math::Libgsl::Matrix::UInt8
* Math::Libgsl::Matrix::Complex32
* Math::Libgsl::Matrix::Complex64

All the following methods are available for the classes correspondig to each datatype, except where noted.

## Vector

### new(Int $size!)

### new(Int :$size!)

The constructor accepts one parameter: the vector's size; it can be passed as a Pair or as a single value.

### list(--> List)

This method returns all the elements of the Vector as a Raku List.

### gist(--> Str)

This method returns the first 100 elements of the Vector interpolated in a Raku Str. The .gist method is used by the Raku say() function and method to print a representation of an object.

### Str(--> Str)

This method returns all the elements of the Vector interpolated in a Raku Str. The .Str method is used by the Raku put() function and method to print an object.

### get(Int:D $index! where \* < $!vector.size --> Num)

This method returns the value of a vector's element. It is possible to address a vector element as a Raku array element:

```
say $vector[1];

```

or even:

```
say $vector[^10];

```

### set(Int:D $index! where \* < $!vector.size, Num(Cool)

This method sets the value of a vector's element. This method can be chained. It is possible to address a vector element as a Raku array element:

```
$vector[1] = 3;

```

Note that it's not possible to set a range of elements (yet). When used as a Raku array, this method can't be chained.

### setall(Num(Cool))

Sets all the elements of the vector to the same value. This method can be chained.

### zero()

Sets all the elements of the vector to zero. This method can be chained.

### basis(Int:D $index! where \* < $!vector.size)

Sets all the elements of the vector to zero except for the element at $index, which is set to one. This method can be chained.

### size(--> UInt)

This method outputs the vector's size.

### write(Str $filename!)

Writes the vector to a file in binary form. This method can be chained.

### read(Str $filename!)

Reads the vector from a file in binary form. This method can be chained.

### printf(Str $filename!, Str $format!)

Writes the vector to a file using the specified format. This method can be chained.

### scanf(Str $filename!)

Reads the vector from a file containing formatted data. This method can be chained.

### copy(Math::Libgsl::Vector $src where $!vector.size == .vector.size)

This method copies the vector $src into the current object. This method can be chained.

### swap(Math::Libgsl::Vector $w where $!vector.size == .vector.size)

This method exchanges the elements of the current vector with the ones of the vector $w. This method can be chained.

### swap-elems(Int $i where \* < $!vector.size, Int $j where \* < $!vector.size)

This method exchanges the $i-th and $j-th elements in place. This method can be chained.

### reverse()

This method reverses the order of the elements of the vector. This method can be chained.

### add(Math::Libgsl::Vector $b where $!vector.size == .vector.size)

### sub(Math::Libgsl::Vector $b where $!vector.size == .vector.size)

### mul(Math::Libgsl::Vector $b where $!vector.size == .vector.size)

### div(Math::Libgsl::Vector $b where $!vector.size == .vector.size)

These methods perform operations on the elements of two vectors. The object on which the method is called is the one whose values are changed. All these methods can be chained.

### scale(Num(Cool) $x)

This method multiplies the elements of the vector by a factor $x. This method can be chained.

### add-constant(Num(Cool) $x)

This method adds a constant to the elements of the vector. This method can be chained.

### sum(--> Num)

This method returns the sum of the elements of the vector. This method fails if the underlying C library's version is less than 2.7.

### axpby(Num(Cool) $alpha, Num(Cool) $beta, Math::Libgsl::Vector $b where $!vector.size == .vector.size)

This method performs the operation αx + βy and returns the result in the vector $b. This method can be chained. This method fails if the underlying C library's version is less than 2.7.

### max(--> Num)

### min(--> Num)

These two methods return the min and max value in the vector. Not available in Math::Libgsl::Vector::Complex32 and Math::Libgsl::Vector::Complex64.

### minmax(--> List)

This method returns a list of two values: the min and max value in the vector. Not available in Math::Libgsl::Vector::Complex32 and Math::Libgsl::Vector::Complex64.

### max-index(--> Int)

### min-index(--> Int)

These two methods return the index of the min and max value in the vector. Not available in Math::Libgsl::Vector::Complex32 and Math::Libgsl::Vector::Complex64.

### minmax-index(--> List)

This method returns a list of two values: the indices of the min and max value in the vector. Not available in Math::Libgsl::Vector::Complex32 and Math::Libgsl::Vector::Complex64.

### is-null(--> Bool)

### is-pos(--> Bool)

### is-neg(--> Bool)

### is-nonneg(--> Bool)

These methods return True if all the elements of the vector are zero, strictly positive, strictly negative, or non-negative.

### is-equal(Math::Libgsl::Vector $b --> Bool)

This method returns True if the two vectors are equal element-wise.

## Views

Views are extremely handy, but their C-language interface uses a couple of low-level tricks that makes difficult to write a simple interface for high-level languages. A View is a reference to data in a Vector, Matrix, or array, so it makes possible to work on a subset of that data without having to duplicate it in memory or do complex address calculation to access it. Since a View is a reference to an object, the programmer needs to take care that the original object doesn't go out of scope, or the virtual machine might deallocate its memory causing the underlying C library to crash. Look in the **examples/** directory for more programs showing what can be done with views.

## Vector View

```
use Math::Libgsl::Vector;

my Math::Libgsl::Vector $v .= new(30);                            # Create a 30-element vector
my Math::Libgsl::Vector::View $vv .= new;                         # Create a Vector View
my Math::Libgsl::Vector $v1 = $vv.subvector-stride($v, 0, 3, 10); # Get a subvector view with stride
$v1.setall(42);                                                   # Set all elements of the subvector view to 42
say $v[^30]; # output: (42 0 0 42 0 0 42 0 0 42 0 0 42 0 0 42 0 0 42 0 0 42 0 0 42 0 0 42 0 0)

```

There are two kinds of Vector Views: a Vector View on a Vector or a Vector View on a Raku array. These are Views of the first kind:

### subvector(Math::Libgsl::Vector $v, size\_t $offset where \* < $v.vector.size, size\_t $n --> Math::Libgsl::Vector)

Creates a view on a subset of the vector, starting from $offset and of length $n. This method returns a new Vector object. Any operation done on this view affects the original vector as well.

### subvector-stride(Math::Libgsl::Vector $v, size\_t $offset where \* < $v.vector.size, size\_t $stride, size\_t $n --> Math::Libgsl::Vector)

Creates a view on a subset of the vector, starting from $offset and of length $n, with stride $stride. This method returns a new Vector object. Any operation done on this view affects the original vector as well.

Views on a Raku array are a bit more complex, because it's not possible to simply pass a Raku array to a C-language function. So for this to work the programmer has to *prepare* the array to be passed to the library. Both the View object and the *prepared* array must not go out of scope.

There are three ways to access a Raku array as a Math::Libgsl::Vector object:

* The hard way - use NativeCall's CArray to create a C-language-happy array.
* The easy way - use the \*-prepvec sub to convert a Raku array into a C array.
* The easiest way - use the \*-array-vec sub, pass it the Raku array or list and a closure or anonymous sub.

This is an example of the "hard way":

```
use Math::Libgsl::Vector;
use NativeCall;

my CArray[num64] $array .= new: (1 xx 10)».Num;         # define a CArray
my Math::Libgsl::Vector::View $vv .= new;               # view: an object that will contain the view information
my Math::Libgsl::Vector $v = $vv.array($array);         # create an Math::Libgsl::Vector object
$v[0] = 2;                                              # assign a value to the first vector element
say $v[^10];                                            # output: (2 1 1 1 1 1 1 1 1 1)

```

This is an example of the "easy way":

```
use Math::Libgsl::Vector;

my @array = 1 xx 10;                                    # define an array
my $parray = num64-prepvec(@array);                     # prepare the array to be used as a Math::Libgsl::Vector
my Math::Libgsl::Vector::View $vv .= new;               # view: an object that will contain the view information
my Math::Libgsl::Vector $v = $vv.array($parray);        # create an Math::Libgsl::Vector object
$v[0] = 2;                                              # assign a value to the first vector element
say $v[^10];                                            # output: (2 1 1 1 1 1 1 1 1 1)

```

Here are some examples of the "easiest way":

```
use Math::Libgsl::Vector;

my @array = ^10;                                                    # initialize an array
my ($min, $max) = num64-array-vec(-> $vec { $vec.minmax }, @array); # find min and max value
say "$min $max";                                                    # output: 0 9

```

```
use Math::Libgsl::Constants;
use Math::Libgsl::Vector;
use Math::Libgsl::MovingWindow;

my @array = ^10;                                        # initialize an array
my Math::Libgsl::MovingWindow $mw .= new: :samples(5);  # initialize a MovingWindow object with a 5-sample window
                                                        # compute the moving-window mean of the array
my $w = num64-array-vec(-> $vec { $mw.mean($vec, :endtype(GSL_MOVSTAT_END_PADVALUE)) }, @array);
say $w[^10];                                            # output: (0.6 1.2 2 3 4 5 6 7 7.8 8.4)

```

Even using this last construct, if the Vector object is to be used outside of the closure it must be declared before calling array-vec.

```
use Math::Libgsl::Vector;

my @array = 1 xx 10;                                            # define an array
my Math::Libgsl::Vector $v .= new: 10;                          # declare a Math::Libgsl::Vector
num64-array-vec(-> $vec { $v.copy($vec); $v[0] = 2; }, @array); # assign a value to the first vector element
say $v[^10];                                                    # output: (2 1 1 1 1 1 1 1 1 1)

```

### num64-prepvec(@array)

This is just a sub, not a method; it gets a regular array and outputs a *prepared* array, kept in a scalar variable. There are similar functions for every data type, so for example if one is working with int16 Vectors, one will use the **int16-prepvec** sub. The num64, being the default data type, has a special **prepvec** alias. Once *prepared*, the original array can be discarded.

### array($parray --> Math::Libgsl::Vector)

This method gets a *prepared* array and returns a Math::Libgsl::Vector object.

### array-stride($array, size\_t $stride --> Math::Libgsl::Vector)

This method gets a *prepared* array and a **$stride** and returns a Math::Libgsl::Vector object.

### sub num64-array-vec(Block $bl, \*@data)

This sub arguments are a Block to execute and a regular Raku array. Internally it uses a vector view to convert the array into libgsl's own vector data type, obtains the Math::Libgsl::Vector from the View, and passes it to the Block. When the Block exits the Math::Libgsl::Vector object ceases to exist, so it must be consumed inside the Block, or copied into another externally defined variable. The num64, being the default data type, has a special **array-vec** alias.

### sub num64-array-stride-vec(Block $bl, size\_t $stride, \*@data)

This sub arguments are a Block to execute, a stride, and a regular Raku array. Internally it uses a vector view to convert the array into libgsl's own vector data type, obtains the Math::Libgsl::Vector from the View, and passes it to the Block. When the Block exits the Math::Libgsl::Vector object ceases to exist, so it must be consumed inside the Block, or copied into another externally defined variable. The num64, being the default data type, has a special **array-stride-vec** alias.

## Matrix

### new(Int $size1!, Int $size2!)

### new(Int :$size1!, Int :$size2!)

The constructor accepts two parameters: the matrix sizes; they can be passed as Pairs or as single values.

All the following methods *throw* on error if they return **self**, otherwise they *fail* on error.

### list(--> List)

This method returns all the elements of the Matrix as a Raku List of Lists.

### gist(--> Str)

This method returns the first 10 elements of the first 10 rows of the Matrix interpolated in a Raku Str. The .gist method is used by the Raku say() function and method to print a representation of an object.

### Str(--> Str)

This method returns all the elements of the Matrix interpolated in a Raku Str. The .Str method is used by the Raku put() function and method to print an object.

### get(Int:D $i! where \* < $!matrix.size1, Int:D $j! where \* < $!matrix.size2 --> Num)

This method returns the value of a matrix element. It is possible to address a matrix element as a Raku shaped array element:

```
say $matrix[1;2];

```

### set(Int:D $i! where \* < $!matrix.size1, Int:D $j! where \* < $!matrix.size2, Num(Cool)

This method sets the value of a matrix element. This method can be chained. It is possible to address a matrix element as a Raku shaped array element:

```
$matrix[1;3] = 3;

```

### setall(Num(Cool))

Sets all the elements of the matrix to the same value. This method can be chained.

### zero()

Sets all the elements of the matrix to zero. This method can be chained.

### identity()

Sets all elements of the matrix to the corrisponding elements of the identity matrix.

### size1(--> UInt)

### size2(--> UInt)

### size(--> List)

These methods return the first, second, or both the matrix sizes.

### write(Str $filename!)

Writes the matrix to a file in binary form. This method can be chained.

### read(Str $filename!)

Reads the matrix from a file in binary form. This method can be chained.

### printf(Str $filename!, Str $format!)

Writes the matrix to a file using the specified format. This method can be chained.

### scanf(Str $filename!)

Reads the matrix from a file containing formatted data. This method can be chained.

### copy(Math::Libgsl::Matrix $src where $!matrix.size1 == .matrix.size1 && $!matrix.size2 == .matrix.size2)

This method copies the $src matrix into the current one. This method can be chained.

### swap(Math::Libgsl::Matrix $src where $!matrix.size1 == .matrix.size1 && $!matrix.size2 == .matrix.size2)

This method swaps elements of the $src matrix and the current one. This method can be chained.

### tricpy(Math::Libgsl::Matrix $src where $!matrix.size1 == .matrix.size1 && $!matrix.size2 == .matrix.size2, Int $Uplo, Int $Diag)

This method copies the upper or lower trianglular matrix from **$src** to **self**. Use the **cblas-uplo** enumeration to specify which triangle copy. Use the **cblas-diag** enumeration to specify whether to copy the matrix diagonal. This method can be chained.

### get-row(Int:D $i where \* < $!matrix.size1)

This method returns an array from row number $i.

### get-col(Int:D $j where \* < $!matrix.size2)

This method returns an array from column number $j.

### set-row(Int:D $i where \* ≤ $!matrix.size1, @row where \*.elems == $!matrix.size2)

### set-row(Int:D $i where \* ≤ $!matrix.size1, Math::Libgsl::Vector $v where .vector.size == $!matrix.size2)

These methods set row number $i of the matrix from a Raku array or a Vector object. This method can be chained.

### set-col(Int:D $j where \* ≤ $!matrix.size2, @col where \*.elems == $!matrix.size1)

### set-col(Int:D $j where \* ≤ $!matrix.size2, Math::Libgsl::Vector $v where .vector.size == $!matrix.size1)

These methods set column number $j of the matrix from a Raku array or a Vector object. This method can be chained.

### swap-rows(Int:D $i where \* ≤ $!matrix.size1, Int:D $j where \* ≤ $!matrix.size1)

This method swaps rows $i and $j. This method can be chained.

### swap-cols(Int:D $i where \* ≤ $!matrix.size2, Int:D $j where \* ≤ $!matrix.size2)

This method swaps columns $i and $j. This method can be chained.

### swap-rowcol(Int:D $i where \* ≤ $!matrix.size1, Int:D $j where \* ≤ $!matrix.size1)

This method exchanges row number $i with column number $j of a square matrix. This method can be chained.

### copy-transpose(Math::Libgsl::Matrix $src where $!matrix.size1 == .matrix.size2 && $!matrix.size2 == .matrix.size1)

This method copies a matrix into the current one, while transposing the elements. This method can be chained.

### transpose()

This method transposes the current matrix. This method can be chained.

### transpose-tricpy(Math::Libgsl::Matrix $src where $!matrix.size1 == .matrix.size2 && $!matrix.size2 == .matrix.size1, Int $Uplo, Int $Diag)

This method copies a triangle from the **$src** matrix into the current one, while transposing the elements. Use the **cblas-uplo** enumeration to specify which triangle copy. Use the **cblas-diag** enumeration to specify whether to copy the matrix diagonal. This method can be chained.

### add(Math::Libgsl::Matrix $b where $!matrix.size1 == .matrix.size1 && $!matrix.size2 == .matrix.size2)

This method adds a matrix to the current one element-wise. This method can be chained.

### sub(Math::Libgsl::Matrix $b where $!matrix.size1 == .matrix.size1 && $!matrix.size2 == .matrix.size2)

This method subtracts a matrix from the current one element-wise. This method can be chained.

### mul(Math::Libgsl::Matrix $b where $!matrix.size1 == .matrix.size1 && $!matrix.size2 == .matrix.size2)

This method multiplies a matrix to the current one element-wise. This method can be chained.

### div(Math::Libgsl::Matrix $b where $!matrix.size1 == .matrix.size1 && $!matrix.size2 == .matrix.size2)

This method divides the current matrix by another one element-wise. This method can be chained.

### scale(Num(Cool) $x)

This method multiplies the elements of the current matrix by a constant value. This method can be chained.

### scale-rows(Math::Libgsl::Vector $x where .size == $!matrix.size1)

This method scales the rows of the M-by-N matrix by the elements of the vector $x, of length N. The i-th row of the matrix is multiplied by $xᵢ. This method can be chained. This method fails if the underlying C library's version is less than 2.7.

### scale-columns(Math::Libgsl::Vector $x where .size == $!matrix.size1)

This method scales the columns of the M-by-N matrix by the elements of the vector $x, of length N. The j-th column of the matrix is multiplied by $xⱼ. This method can be chained. This method fails if the underlying C library's version is less than 2.7.

### add-constant(Num(Cool) $x)

This method adds a constant to the elements of the current matrix. This method can be chained.

### max(--> Num)

### min(--> Num)

These two methods return the min and max value in the matrix. Not available in Math::Libgsl::Matrix::Complex32 and Math::Libgsl::Matrix::Complex64.

### minmax(--> List)

This method returns a list of two values: the min and max value in the matrix. Not available in Math::Libgsl::Matrix::Complex32 and Math::Libgsl::Matrix::Complex64.

### max-index(--> Int)

### min-index(--> Int)

These two methods return the index of the min and max value in the matrix. Not available in Math::Libgsl::Matrix::Complex32 and Math::Libgsl::Matrix::Complex64.

### minmax-index(--> List)

This method returns a list of two values: the indices of the min and max value in the matrix. Not available in Math::Libgsl::Matrix::Complex32 and Math::Libgsl::Matrix::Complex64.

### is-null(--> Bool)

### is-pos(--> Bool)

### is-neg(--> Bool)

### is-nonneg(--> Bool)

These methods return True if all the elements of the matrix are zero, strictly positive, strictly negative, or non-negative.

### is-equal(Math::Libgsl::Matrix $b --> Bool)

This method returns True if the matrices are equal element-wise.

### norm1(--> Num)

This method returns the 1-norm of the m-by-n matrix, defined as the maximum column sum. This method fails if the underlying C library's version is less than 2.7.

## Matrix View

```
use Math::Libgsl::Matrix;

my Math::Libgsl::Matrix $m1 .= new(:size1(3), :size2(4));      # create a 3x4 matrix
$m1.setall(1);                                                 # set all elements to 1
my Math::Libgsl::Matrix::View $mv .= new;                      # create a Matrix View
my Math::Libgsl::Matrix $m2 = $mv.submatrix($m1, 1, 1, 2, 2);  # get a submatrix
$m2.setall(12);                                                # set the submatrix elements to 12
$m1.get-row($_)».fmt('%2d').put for ^3;                        # print the original matrix
# output:
# 1  1  1  1
# 1 12 12  1
# 1 12 12  1

```

There are three kinds of Matrix Views: a Matrix View on a Matrix, a Matrix View on a Vector, and a Matrix View on a Raku array.

This is the View of the first kind:

### submatrix(Math::Libgsl::Matrix $m, size\_t $k1 where \* < $m.size1, size\_t $k2 where \* < $m.size2, size\_t $n1, size\_t $n2 --> Math::Libgsl::Matrix)

Creates a view on a subset of the matrix, starting from coordinates ($k1, $k2) with $n1 rows and $n2 columns. This method returns a new Matrix object. Any operation done on the returned matrix affects the original matrix as well.

These three methods create a matrix view on a Raku array:

There are three ways to view a Raku array as a Math::Libgsl::Vector object:

* The hard way - use NativeCall's CArray to create a C-language-happy array.
* The easy way - use the \*-prepvec sub to convert a Raku array into a C array.
* The easiest way - use the \*-array-vec sub, pass it the Raku array or list and a closure or anonymous sub.

This is an example of the "hard way":

```
use Math::Libgsl::Matrix;
use NativeCall;

my CArray[num64] $array .= new: (1..6)».Num;            # define a CArray
my Math::Libgsl::Matrix::View $mv .= new;               # view: an object that will contain the view information
my Math::Libgsl::Matrix $m = $mv.array($array, 2, 3);   # create an Math::Libgsl::Matrix object
$m[0;0] = 2;                                            # assign a value to the first matrix element
say $m.get-row($_) for ^2;
# output:
# 2 2 3
# 4 5 6

```

This is an example of the "easy way":

Views on a Raku array are a bit more complex, because it's not possible to simply pass a Raku array to a C-language function. So for this to work the programmer has to *prepare* the array to be passed to the library. Both the View object and the *prepared* array must not go out of scope.

```
use Math::Libgsl::Matrix;

my @array = 1 xx 10;                                    # define an array
my $parray = prepmat(@array);                           # prepare the array to be used as a Math::Libgsl::Matrix
my Math::Libgsl::Matrix::View $mv .= new;               # view: an object that will contain the view information
my Math::Libgsl::Matrix $m = $mv.array($parray, 2, 5);  # create an Math::Libgsl::Matrix object
$m[0;0] = 2;                                            # assign a value to the first matrix element
$m.get-row($_).put for ^2;
# output:
# 2 1 1 1 1
# 1 1 1 1 1

```

This is an example of the "easiest way":

```
use Math::Libgsl::Matrix;

my @array = 1..6;                                                                 # initialize an array
my Math::Libgsl::Matrix $matrix .= new: 2, 3;                                     # declare a Math::Libgsl::Matrix
num64-array-mat(-> $mat { $matrix.copy($mat); $matrix[0;0] = 0 }, 2, 3, @array);  # assign 0 to matrix element [0;0]
$matrix.get-row($_).put for ^2;
# output:
# 0 2 3
# 4 5 6

```

### num64-prepmat(@array)

This is just a sub, not a method; it gets a regular array and outputs a *prepared* array, kept in a scalar variable. There are similar functions for every data type, so for example if one is working with int16 Vectors, one will use the **int16-prepmat** sub. The num64, being the default data type, has a special **prepmat** alias. Once *prepared*, the original array can be discarded.

### array($array, UInt $size1, UInt $size2 --> Math::Libgsl::Matrix)

This method gets a *prepared* array and returns a Math::Libgsl::Matrix object.

### array-tda($array, UInt $size1, UInt $size2, size\_t $tda where \* > $size2 --> Math::Libgsl::Matrix)

This method gets a *prepared* array with a number of physical columns **$tda**, which may differ from the corresponding dimension of the matrix, and returns a Math::Libgsl::Matrix object.

### sub num64-array-mat(Block $bl, UInt $size1, UInt $size2, \*@data)

This sub arguments are a Block to execute, the sizes of the desired resulting matrix, and a regular Raku array. Internally it uses a matrix view to convert the array into libgsl's own matrix data type, obtains the Math::Libgsl::Matrix from the View, and passes it to the Block. When the Block exits the Math::Libgsl::Matrix object ceases to exist, so it must be consumed inside the Block, or copied into another externally defined variable. The num64, being the default data type, has a special **array-mat** alias.

### sub num64-array-tda-mat(Block $bl, UInt $size1, UInt $size2, size\_t $tda where \* > $size2, \*@data)

This sub arguments are a Block to execute, the sizes of the desired resulting matrix, the number of physical columns **$tda**, and a regular Raku array. Internally it uses a matrix view to convert the array into libgsl's own matrix data type, obtains the Math::Libgsl::Matrix from the View, and passes it to the Block. When the Block exits the Math::Libgsl::Matrix object ceases to exist, so it must be consumed inside the Block, or copied into another externally defined variable. The num64, being the default data type, has a special **array-tda-mat** alias.

There are two methods to create a Matrix View on a Vector:

### vector(Math::Libgsl::Vector $v, size\_t $n1, size\_t $n2 --> Math::Libgsl::Matrix)

This method creates a Matrix object from a Vector object. The resultimg matrix will have $n1 rows and $n2 columns.

### vector-tda(Math::Libgsl::Vector $v, size\_t $n1, size\_t $n2, size\_t $tda where \* > $n2 --> Math::Libgsl::Matrix)

This method creates a Matrix object from a Vector object, with a physical number of columns $tda which may differ from the correspondig dimension of the matrix. The resultimg matrix will have $n1 rows and $n2 columns.

## Vector View on a Matrix

There is a fourth kind of View that involves a Matrix: a Vector View on a Matrix. The following are methods of the Matrix class, not of the Matrix::View class, take a Vector::View argument, and deliver a Vector object. The Matrix object must not go out of scope while one is operating on the resulting Vector.

### row-view(Math::Libgsl::Vector::View $vv, size\_t $i where \* < $!matrix.size1 --> Math::Libgsl::Vector)

This method creates a Vector object from row $i of the matrix.

### col-view(Math::Libgsl::Vector::View $vv, size\_t $j where \* < $!matrix.size2 --> Math::Libgsl::Vector)

This method creates a Vector object from column $j of the matrix.

### subrow-view(Math::Libgsl::Vector::View $vv, size\_t $i where \* < $!matrix.size1, size\_t $offset, size\_t $n --> Math::Libgsl::Vector)

This method creates a Vector object from row $i of the matrix, starting from $offset and containing $n elements.

### subcol-view(Math::Libgsl::Vector::View $vv, size\_t $j where \* < $!matrix.size2, size\_t $offset, size\_t $n --> Math::Libgsl::Vector)

This method creates a Vector object from column $j of the matrix, starting from $offset and containing $n elements.

### diagonal-view(Math::Libgsl::Vector::View $vv --> Math::Libgsl::Vector)

This method creates a Vector object from the diagonal of the matrix.

### subdiagonal-view(Math::Libgsl::Vector::View $vv, size\_t $k where \* < min($!matrix.size1, $!matrix.size2) --> Math::Libgsl::Vector)

This method creates a Vector object from the subdiagonal number $k of the matrix.

### superdiagonal-view(Math::Libgsl::Vector::View $vv, size\_t $k where \* < min($!matrix.size1, $!matrix.size2) --> Math::Libgsl::Vector)

This method creates a Vector object from the superdiagonal number $k of the matrix.

# C Library Documentation

For more details on


## dist_zef-FRITH-Math-Libgsl-Matrix.md
## Chunk 2 of 2
 libgsl see <https://www.gnu.org/software/gsl/>. The excellent C Library manual is available here <https://www.gnu.org/software/gsl/doc/html/index.html>, or here <https://www.gnu.org/software/gsl/doc/latex/gsl-ref.pdf> in PDF format.

# Prerequisites

This module requires the libgsl library to be installed. Please follow the instructions below based on your platform:

## Debian Linux and Ubuntu 20.04

```
sudo apt install libgsl23 libgsl-dev libgslcblas0

```

That command will install libgslcblas0 as well, since it's used by the GSL.

## Ubuntu 18.04

libgsl23 and libgslcblas0 have a missing symbol on Ubuntu 18.04. I solved the issue installing the Debian Buster version of those three libraries:

* <http://http.us.debian.org/debian/pool/main/g/gsl/libgslcblas0_2.5+dfsg-6_amd64.deb>
* <http://http.us.debian.org/debian/pool/main/g/gsl/libgsl23_2.5+dfsg-6_amd64.deb>
* <http://http.us.debian.org/debian/pool/main/g/gsl/libgsl-dev_2.5+dfsg-6_amd64.deb>

# Installation

To install it using zef (a module management tool):

```
$ zef install Math::Libgsl::Matrix

```

# AUTHOR

Fernando Santagata [nando.santagata@gmail.com](mailto:nando.santagata@gmail.com)

# COPYRIGHT AND LICENSE

Copyright 2020 Fernando Santagata

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


## dist_github-Skarsnik-IRC-Art.md
[![Build Status](https://travis-ci.org/Skarsnik/perl6-irc-art.svg?branch=master)](https://travis-ci.org/Skarsnik/perl6-irc-art)

# Name IRC::Art

# Synopsis

```
use IRC::Art;
use YourFavoriteIrcClient;

my $art = IRC::Art.new(4, 4); # A 4x4
$art.rectangle(0, 0, 3, 3, :color(4)); #draw a red square
$art.text("6.c", 1, 1, :color(13), :bold); # put the 6.c text starting at 1,1
for $art.result {
  $irc.send-message('#perl6', $_);
}

```

# Description

IRC::Art offers you a way to create basic art on IRC. It works mainly like a small graphics library with methods to "draw" like pixel, text or rectangle.

# Usage

Create an `IRC::Art` object and use the various drawing methods on it. Every change writes over the previous of the existing execpt for the text method.

## new(?width, ?height)

Create a new canvas filled with blanks (space), sized according to the width and height information.

## result

Returns the canvas as an array of irc strings that you can put in a loop to send the art.

## Str

The `Str` method returns the first row of the canvas as a single string.

## pixel($x, $y, :$color, $clear)

Place or clear the pixel at the given x/y coordinate

## rectangle($x1, $y1, $x2, $y2, :$color, $clear)

Place or clear a rectangle of pixels from x1/y1 to x2/y2 corners

## text($text, $x, $y, :$color, $bold, $bg)

Place some text, starting at the x/y coordonates.

$color is the color of the text

$bg is the color of the background

## save($filename) load($filename)

Save the canvas in a Perl 6. Use load to load it.

# Colors

These color are mainly indicative, it depends too much on the irc client configuration.

```
0 : light grey
1 : Black
2 : Dark Blue
3 : Dark Green
4 : Red
5 : Dark red
6 : Violet
7 : Orange
8 : Yellow
9 : Light Green
10 : Dark light blue
11 : Lighter blue
12 : Blue
13 : Pink
14 : Dark Grey
15 : Grey

```


## dist_zef-rbt-File-Temp.md
[![Build status](https://ci.appveyor.com/api/projects/status/github/perlpilot/p6-File-Temps?svg=true)](https://ci.appveyor.com/project/perlpilot/p6-File-Temps/branch/master)

# NAME

File::Temp

# SYNOPSIS

```
# Generate a temp file in a temp dir
my ($filename,$filehandle) = tempfile;

# specify a template for the filename
#  * are replaced with random characters
my ($filename,$filehandle) = tempfile("******");

# Automatically unlink files at DESTROY (this is the default)
my ($filename,$filehandle) = tempfile("******", :unlink);

# Specify the directory where the tempfile will be created
my ($filename,$filehandle) = tempfile(:tempdir("/path/to/my/dir"));

# don't unlink this one
my ($filename,$filehandle) = tempfile(:tempdir('.'), :!unlink);

# specify a prefix and suffix for the filename
my ($filename,$filehandle) = tempfile(:prefix('foo'), :suffix(".txt"));

```

# DESCRIPTION

This module exports two routines:

* `tempfile` creates a temporary file and returns a filehandle to that file
  opened for writing and the filename of that temporary file
* `tempdir` creates a temporary directory and returns the directory name.

# AUTHOR

Jonathan Scott Duff [duff@pobox.com](mailto:duff@pobox.com)


## mixhash.md
class MixHash

Mutable collection of distinct objects with Real weights

```raku
class MixHash does Mixy { }
```

A `MixHash` is a mutable mix, meaning a collection of distinct elements in no particular order that each have a real-number weight assigned to them. (For *immutable* mixes, see [`Mix`](/type/Mix) instead.)

Objects/values of any type are allowed as mix elements. Within a `MixHash`, items that would compare positively with the [===](/routine/===) operator are considered the same element, with a combined weight.

```raku
my $recipe = (butter => 0.22, sugar => 0.1,
              flour => 0.275, sugar => 0.02).MixHash;

say $recipe.elems;      # OUTPUT: «3␤»
say $recipe.keys.sort;  # OUTPUT: «butter flour sugar␤»
say $recipe.pairs.sort; # OUTPUT: «"butter" => 0.22 "flour" => 0.275 "sugar" => 0.12␤»
say $recipe.total;      # OUTPUT: «0.615␤»

```

`MixHash`es can be treated as object hashes using the [`{ }` postcircumfix operator](/language/operators#postcircumfix_{_}), or the [`< >` postcircumfix operator](/language/operators#postcircumfix_<_>) for literal string keys, which returns the corresponding numeric weight for keys that are elements of the mix, and `0` for keys that aren't. It can also be used to modify weights; Setting a weight to `0` automatically removes that element from the mix, and setting a weight to a non-zero number adds that element if it didn't already exist:

```raku
my $recipe = (butter => 0.22, sugar => 0.1,
              flour => 0.275, sugar => 0.02).MixHash;

say $recipe<butter>;     # OUTPUT: «0.22␤»
say $recipe<sugar>;      # OUTPUT: «0.12␤»
say $recipe<chocolate>;  # OUTPUT: «0␤»

$recipe<butter> = 0;
$recipe<chocolate> = 0.30;
say $recipe.pairs;       # OUTPUT: «"sugar" => 0.12 "flour" => 0.275 "chocolate" => 0.3␤»

```

# [Creating `MixHash` objects](#class_MixHash "go to top of document")[§](#Creating_MixHash_objects "direct link")

`MixHash`es can be composed using `MixHash.new`. Any positional parameters, regardless of their type, become elements of the mix - with a weight of `1` for each time the parameter occurred:

```raku
my $n = MixHash.new: "a", "a", "b" => 0, "c" => 3.14;
say $n.keys.map(&WHAT);  # OUTPUT: «((Str) (Pair) (Pair))␤»
say $n.pairs;            # OUTPUT: «(a => 2 (c => 3.14) => 1 (b => 0) => 1)␤»
```

Alternatively, the `.MixHash` coercer (or its functional form, `MixHash()`) can be called on an existing object to coerce it to a `MixHash`. Its semantics depend on the type and contents of the object. In general it evaluates the object in list context and creates a mix with the resulting items as elements, although for Hash-like objects or Pair items, only the keys become elements of the mix, and the (cumulative) values become the associated numeric weights:

```raku
my $n = ("a", "a", "b" => 0, "c" => 3.14).MixHash;
say $n.keys.map(&WHAT);  # OUTPUT: «((Str) (Str))␤»
say $n.pairs;            # OUTPUT: «(a => 2 c => 3.14)␤»
```

Since 6.d (2019.03 and later) it is also possible to specify the type of values you would like to allow in a `MixHash`. This can either be done when calling `.new`:

```raku
# only allow strings
my $n = MixHash[Str].new: <a b b c c c>;
```

or using the masquerading syntax:

```raku
# only allow strings
my %mh is MixHash[Str] = <a b b c c c>;
say %mh<b>;  # OUTPUT: «2␤»
say %mh<d>;  # OUTPUT: «0␤»

# only allow whole numbers
my %mh is MixHash[Int] = <a b b c c c>;
# Type check failed in binding; expected Int but got Str ("a")
```

# [Operators](#class_MixHash "go to top of document")[§](#Operators "direct link")

See [Operators with set semantics](/language/setbagmix#Operators_with_set_semantics) for a complete list of "set operators" applicable to, among other types, `MixHash`.

Examples:

```raku
my ($a, $b) = MixHash(2 => 2, 4), MixHash(2 => 1.5, 3 => 2, 4);

say $a (<) $b;   # OUTPUT: «False␤»
say $a (<=) $b;  # OUTPUT: «False␤»
say $a (^) $b;   # OUTPUT: «MixHash(2(0.5) 3(2))␤»
say $a (+) $b;   # OUTPUT: «MixHash(2(3.5) 4(2) 3(2))␤»

# Unicode versions:
say $a ⊂ $b;  # OUTPUT: «False␤»
say $a ⊆ $b;  # OUTPUT: «False␤»
say $a ⊖ $b;  # OUTPUT: «MixHash(2(0.5) 3(2))␤»
say $a ⊎ $b;  # OUTPUT: «MixHash(2(3.5) 4(2) 3(2))␤»

```

# [Note on `reverse` and ordering.](#class_MixHash "go to top of document")[§](#Note_on_reverse_and_ordering. "direct link")

MixHash inherits `reverse` from [Any](/type/Any#routine_reverse), however, [`Mix`](/type/Mix)es do not have an inherent order and you should not trust it returning a consistent output.

If you sort a MixHash, the result is a list of pairs, at which point `reverse` makes perfect sense:

```raku
my $a = MixHash.new(2, 2, 18, 3, 4);
say $a;  # OUTPUT: «MixHash(18 2(2) 3 4)␤»

say $a.sort;  # OUTPUT: «(2 => 2 3 => 1 4 => 1 18 => 1)␤»
say $a.sort.reverse;  # OUTPUT: «(18 => 1 4 => 1 3 => 1 2 => 2)␤»

```

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

## [method Bag](#class_MixHash "go to top of document")[§](#method_Bag "direct link")

```raku
method Bag (--> Bag:D)
```

Coerces the `MixHash` to a [`Bag`](/type/Bag). The weights are converted to [`Int`](/type/Int), which means the number of keys in the resulting [`Bag`](/type/Bag) can be fewer than in the original `MixHash`, if any of the weights are negative or truncate to zero.

## [method BagHash](#class_MixHash "go to top of document")[§](#method_BagHash "direct link")

```raku
method BagHash (--> BagHash:D)
```

Coerces the `MixHash` to a [`BagHash`](/type/BagHash). The weights are converted to [`Int`](/type/Int), which means the number of keys in the resulting [`BagHash`](/type/BagHash) can be fewer than in the original `MixHash`, if any of the weights are negative or truncate to zero.

# [See Also](#class_MixHash "go to top of document")[§](#See_Also "direct link")

[Sets, Bags, and Mixes](/language/setbagmix)

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

Type relations for `MixHash`

raku-type-graph

MixHash
MixHash

Any
Any

MixHash->Any

Mixy
Mixy

MixHash->Mixy

Mu
Mu

Any->Mu

Associative
Associative

QuantHash
QuantHash

QuantHash->Associative

Baggy
Baggy

Baggy->QuantHash

Mixy->Baggy

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


## uint.md
Subset UInt

Unsigned integer (arbitrary-precision)

The `UInt` is defined as a subset of [`Int`](/type/Int):

```raku
my subset UInt of Int where {not .defined or $_ >= 0};

```

Consequently, it cannot be instantiated or subclassed; however, that shouldn't affect most normal uses.

Some examples of its behavior and uses:

```raku
say UInt ~~ Int; # OUTPUT: «True␤»
my UInt $u = 0xffff_ffff_ffff_ffff_ffff_ffff_ffff_ffff; # 64-bit unsigned value
say $u.base(16); # OUTPUT: «FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF␤» (32 digits)
++$u;
say $u.base(16); # OUTPUT: «100000000000000000000000000000000␤» (33 digits!)
my Int $i = $u;
say $i.base(16); # same as above
say $u.^name;    # OUTPUT: «Int␤» - UInt is a subset, so the type is still Int.
say $i.^name;    # OUTPUT: «Int␤»
# Difference in assignment
my UInt $a = 5;  # nothing wrong
my UInt $b = -5; # Exception about failed type check
my UInt $c = 0;
--$c;            # Exception again
CATCH { default { put .^name, ': ', .Str } };
# OUTPUT: «X::TypeCheck::Assignment: Type check failed in assignment to $b; expected UInt but got Int (-5)␤»

# Non-assignment operations are fine
my UInt $d = 0;
say $d - 3;      # OUTPUT: «-3␤»
```

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

Type relations for `UInt`

raku-type-graph

UInt
UInt

Any
Any

UInt->Any

Mu
Mu

Any->Mu

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


## dist_cpan-BDUGGAN-Geo-Basic.md
# NAME

Geo::Basic - Basic geospatial functions

# SYNOPSIS

```
use Geo::Basic;
my $hash = geohash-encode lat => 51.435, lon => -0.215, precision => 5;
# "gcpue5"

my $decoded = geohash-decode $hash;
# %( lat-max => 51.416016, lat-min => 51.459961,
#    lon-max => -0.219727, lon-min => -0.175781 )

my $neighbors = geohash-neighbors $hash;
# [gcpuek gcpueh gcpudu gcpue7 gcpudg gcpue6 gcpue4 gcpudf]

my $distance-km = haversine-km :lat1(51.435), :lon1(-0.215), :lat2(51.435), :lon2(-0.214);
# 0.06931914818231608

my $distance-mi = haversine-miles :lat1(51.435), :lon1(-0.215), :lat2(51.435), :lon2(-0.214);
# 0.04307292175092216

```

# DESCRIPTION

These are a few simple utilities for doing geospatial calculations. The following functions are provided:

```
* `geohash-encode` -- encode a latitude and longitude into a geohash
* `geohash-decode` -- decode a geohash into a latitude and longitude
* `geohash-neighbors` -- find the neighbors of a geohash
* `haversine-km` -- calculate the distance between two points on the earth in kilometers
* `haversine-miles` -- calculate the distance between two points on the earth in miles

```

# FUNCTIONS

### sub geohash-encode

```
sub geohash-encode(
    Rat(Real) :$lat,
    Rat(Real) :$lon,
    Int :$precision = 9
) returns Mu

```

Encode a latitude and longitude into a geohash

### sub geohash-decode

```
sub geohash-decode(
    Str $geo
) returns Hash

```

Decode a geohash into a latitude and longitude

### sub radians

```
sub radians(
    Real $deg
) returns Mu

```

Convert degrees to radians

### sub km-to-miles

```
sub km-to-miles(
    Real $km
) returns Mu

```

Convert kilometers to miles

### sub haversine-miles

```
sub haversine-miles(
    Real :$lat1,
    Real :$lon1,
    Real :$lat2,
    Real :$lon2
) returns Mu

```

Calculate the great circle distance in miles, using the havarsine formula

### sub haversine-km

```
sub haversine-km(
    Real :$lat1,
    Real :$lon1,
    Real :$lat2,
    Real :$lon2
) returns Mu

```

Calculate the great circle distance in kilometers using the havarsine formula

# AUTHOR

Brian Duggan

Original geohash code by Thundergnat on Rosetta Code


## date.md
class Date

Calendar date

```raku
class Date { }
```

A `Date` is an immutable object identifying a day in the Gregorian calendar.

`Date` objects support addition and subtraction of integers, where an integer is interpreted as the number of days. You can compare `Date` objects with the numeric comparison operators `==, <, <=, >, >=, !=`. Their stringification in `YYYY-MM-DD` format means that comparing them with the string operators `eq, lt, le` etc. also gives the right result.

`Date.today` creates an object the current day according to the system clock.

```raku
my $d = Date.new(2015, 12, 24); # Christmas Eve!
say $d;                         # OUTPUT: «2015-12-24␤»
say $d.year;                    # OUTPUT: «2015␤»
say $d.month;                   # OUTPUT: «12␤»
say $d.day;                     # OUTPUT: «24␤»
say $d.day-of-week;             # OUTPUT: «4␤» (Thursday)
say $d.later(days => 20);       # OUTPUT: «2016-01-13␤»
my $n = Date.new('2015-12-31'); # New Year's Eve
say $n - $d;                    # OUTPUT: «7␤», 7 days between New Years/Christmas Eve
say $n + 1;                     # OUTPUT: «2016-01-01␤»
```

**Note** since version 6.d, .raku can be called on `Date`. It will also reject synthetic numerics such as 7̈ .

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

## [method new](#class_Date "go to top of document")[§](#method_new "direct link")

```raku
multi method new($year, $month, $day, :&formatter --> Date:D)
multi method new(:$year!, :$month = 1, :$day = 1  --> Date:D)
multi method new(Str $date                        --> Date:D)
multi method new(Instant:D $dt                    --> Date:D)
multi method new(DateTime:D $dt                   --> Date:D)
```

Creates a new `Date` object, either from a triple of (year, month, day) that can be coerced to integers, or from a string of the form `YYYY-MM-DD` ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)), or from an Instant or DateTime object. Optionally accepts a formatter as a named parameter.

```raku
my $date = Date.new(2042, 1, 1);
$date = Date.new(year => 2042, month => 1, day => 1);
$date = Date.new("2042-01-01");
$date = Date.new(Instant.from-posix: 1482155532);
$date = Date.new(DateTime.now);
```

Since Rakudo 2022.03, the "day" argument can also be a callable, with `*` representing the last day in a month, and the possibility of getting to the day counting from the last one:

```raku
say Date.new(2042, 2, *); # OUTPUT: «2042-02-28␤»
say Date.new(2044, 2, *); # OUTPUT: «2044-02-29␤»
```

## [method new-from-daycount](#class_Date "go to top of document")[§](#method_new-from-daycount "direct link")

```raku
method new-from-daycount($daycount,:&formatter --> Date:D)
```

Creates a new `Date` object given `$daycount` which is the number of days from epoch Nov. 17, 1858, i.e. the [Modified Julian Day](https://en.wikipedia.org/wiki/Julian_day). Optionally accepts a formatter as a named parameter.

```raku
say Date.new-from-daycount(49987);          # OUTPUT: «1995-09-27␤»
```

## [method daycount](#class_Date "go to top of document")[§](#method_daycount "direct link")

```raku
method daycount(Date:D: --> Int:D)
```

Returns the number of days from epoch Nov. 17, 1858, i.e. the [Modified Julian Day](https://en.wikipedia.org/wiki/Julian_day).

## [method last-date-in-month](#class_Date "go to top of document")[§](#method_last-date-in-month "direct link")

```raku
method last-date-in-month(Date:D: --> Date:D)
```

Returns the last date in the month of the `Date` object. Otherwise, returns the invocant if the day value is already the last day of the month.

```raku
say Date.new('2015-11-24').last-date-in-month; # OUTPUT: «2015-11-30␤»
```

This should allow for much easier ranges like

```raku
$date .. $date.last-date-in-month

```

for all remaining dates in the month.

## [method first-date-in-month](#class_Date "go to top of document")[§](#method_first-date-in-month "direct link")

```raku
method first-date-in-month(Date:D: --> Date:D)
```

Returns the first date in the month of the `Date` object. Otherwise, returns the invocant if the day value is already the first day of the month.

```raku
say Date.new('2015-11-24').first-date-in-month; # OUTPUT: «2015-11-01␤»
```

## [method clone](#class_Date "go to top of document")[§](#method_clone "direct link")

```raku
method clone(Date:D: :$year, :$month, :$day, :&formatter)
```

Creates a new `Date` object based on the invocant, but with the given arguments overriding the values from the invocant.

```raku
say Date.new('2015-11-24').clone(month => 12);    # OUTPUT: «2015-12-24␤»
```

## [method today](#class_Date "go to top of document")[§](#method_today "direct link")

```raku
method today(:&formatter --> Date:D)
```

Returns a `Date` object for the current day. Optionally accepts a formatter named parameter.

```raku
say Date.today;
```

## [method truncated-to](#class_Date "go to top of document")[§](#method_truncated-to "direct link")

```raku
method truncated-to(Date:D: Cool $unit)
```

Returns a `Date` truncated to the first day of its year, month or week. For example

```raku
my $c = Date.new('2012-12-24');
say $c.truncated-to('year');     # OUTPUT: «2012-01-01␤»
say $c.truncated-to('month');    # OUTPUT: «2012-12-01␤»
say $c.truncated-to('week');     # OUTPUT: «2012-12-24␤», because it's Monday already
```

## [method succ](#class_Date "go to top of document")[§](#method_succ "direct link")

```raku
method succ(Date:D: --> Date:D)
```

Returns a `Date` of the following day. "succ" is short for "successor".

```raku
say Date.new("2016-02-28").succ;   # OUTPUT: «2016-02-29␤»
```

## [method pred](#class_Date "go to top of document")[§](#method_pred "direct link")

```raku
method pred(Date:D: --> Date:D)
```

Returns a `Date` of the previous day. "pred" is short for "predecessor".

```raku
say Date.new("2016-01-01").pred;   # OUTPUT: «2015-12-31␤»
```

## [method Str](#class_Date "go to top of document")[§](#method_Str "direct link")

```raku
multi method Str(Date:D: --> Str:D)
```

Returns a string representation of the invocant, as specified by [the formatter](/type/Dateish#method_formatter). If no formatter was specified, an ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)) date will be returned.

```raku
say Date.new('2015-12-24').Str;                     # OUTPUT: «2015-12-24␤»

my $fmt = { sprintf "%02d/%02d/%04d", .month, .day, .year };
say Date.new('2015-12-24', formatter => $fmt).Str;  # OUTPUT: «12/24/2015␤»
```

## [method gist](#class_Date "go to top of document")[§](#method_gist "direct link")

```raku
multi method gist(Date:D: --> Str:D)
```

Returns the date in `YYYY-MM-DD` format ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601))

```raku
say Date.new('2015-12-24').gist;                    # OUTPUT: «2015-12-24␤»
```

## [method Date](#class_Date "go to top of document")[§](#method_Date "direct link")

```raku
method Date(--> Date)
```

Returns the invocant.

```raku
say Date.new('2015-12-24').Date;  # OUTPUT: «2015-12-24␤»
say Date.Date;                    # OUTPUT: «(Date)␤»
```

## [method DateTime](#class_Date "go to top of document")[§](#method_DateTime "direct link")

```raku
multi method DateTime(Date:U: --> DateTime:U)
multi method DateTime(Date:D: --> DateTime:D)
```

Converts the invocant to [`DateTime`](/type/DateTime)

```raku
say Date.new('2015-12-24').DateTime; # OUTPUT: «2015-12-24T00:00:00Z␤»
say Date.DateTime;                   # OUTPUT: «(DateTime)␤»
```

## [method Int](#class_Date "go to top of document")[§](#method_Int "direct link")

```raku
multi method Int(Date:D: --> Int:D)
```

Converts the invocant to [`Int`](/type/Int). The same value can be obtained with the `daycount` method.

Available as of release 2023.02 of the Rakudo compiler.

## [method Real](#class_Date "go to top of document")[§](#method_Real "direct link")

```raku
multi method Real(Date:D: --> Int:D)
```

Converts the invocant to [`Int`](/type/Int). The same value can be obtained with the `daycount` method.

Available as of release 2023.02 of the Rakudo compiler.

## [method Numeric](#class_Date "go to top of document")[§](#method_Numeric "direct link")

```raku
multi method Numeric(Date:D: --> Int:D)
```

Converts the invocant to [`Int`](/type/Int). The same value can be obtained with the `daycount` method. This allows `Date` objects to be used directly in arithmetic operations.

Available as of release 2023.02 of the Rakudo compiler.

# [Functions](#class_Date "go to top of document")[§](#Functions "direct link")

## [sub sleep](#class_Date "go to top of document")[§](#sub_sleep "direct link")

```raku
sub sleep($seconds = Inf --> Nil)
```

Attempt to sleep for the given number of `$seconds`. Returns [`Nil`](/type/Nil) on completion. Accepts [`Int`](/type/Int), [`Num`](/type/Num), [`Rat`](/type/Rat), or [`Duration`](/type/Duration) types as an argument since all of these also do [`Real`](/type/Real).

```raku
sleep 5;                # Int
sleep 5.2;              # Num
sleep (5/2);            # Rat
sleep (now - now + 5);  # Duration

```

It is thus possible to sleep for a non-integer amount of time. For instance, the following code shows that `sleep (5/2)` sleeps for 2.5 seconds and `sleep 5.2` sleeps for 5.2 seconds:

```raku
my $before = now;
sleep (5/2);
my $after = now;
say $after-$before;  # OUTPUT: «2.502411561␤»

$before = now;
sleep 5.2;
$after = now;
say $after-$before;  # OUTPUT: «5.20156987␤»
```

## [sub sleep-timer](#class_Date "go to top of document")[§](#sub_sleep-timer "direct link")

```raku
sub sleep-timer(Real() $seconds = Inf --> Duration:D)
```

This function is implemented like `sleep`, but unlike the former it does return a [`Duration`](/type/Duration) instance with the number of seconds the system did not sleep.

In particular, the returned [`Duration`](/type/Duration) will handle the number of seconds remaining when the process has been awakened by some external event (e.g., Virtual Machine or Operating System events). Under normal condition, when sleep is not interrupted, the returned [`Duration`](/type/Duration) has a value of `0`, meaning no extra seconds remained to sleep. Therefore, in normal situations:

```raku
say sleep-timer 3.14;  # OUTPUT: «0␤»
```

The same result applies to edge cases, when a negative or zero time to sleep is passed as argument:

```raku
say sleep-timer -2; # OUTPUT: 0
say sleep-timer 0;  # OUTPUT: 0

```

See also [sleep-until](/routine/sleep-until).

## [sub sleep-until](#class_Date "go to top of document")[§](#sub_sleep-until "direct link")

```raku
sub sleep-until(Instant $until --> Bool)
```

Works similar to `sleep` but checks the current time and keeps sleeping until the required instant in the future has been reached. It uses internally the `sleep-timer` method in a loop to ensure that, if accidentally woken up early, it will wait again for the specified amount of time remaining to reach the specified instant. goes back to sleep

Returns `True` if the [`Instant`](/type/Instant) in the future has been achieved (either by mean of sleeping or because it is right now), `False` in the case an [`Instant`](/type/Instant) in the past has been specified.

To sleep until 10 seconds into the future, one could write something like this:

```raku
say sleep-until now+10;   # OUTPUT: «True␤»
```

Trying to sleep until a time in the past doesn't work:

```raku
my $instant = now - 5;
say sleep-until $instant; # OUTPUT: «False␤»
```

However if we put the instant sufficiently far in the future, the sleep should run:

```raku
my $instant = now + 30;
# assuming the two commands are run within 30 seconds of one another...
say sleep-until $instant; # OUTPUT: «True␤»

```

To specify an exact instant in the future, first create a [`DateTime`](/type/DateTime) at the appropriate point in time, and cast to an [`Instant`](/type/Instant).

```raku
my $instant = DateTime.new(
    year => 2023,
    month => 9,
    day => 1,
    hour => 22,
    minute => 5);
say sleep-until $instant.Instant; # OUTPUT: «True␤» (eventually...)

```

This could be used as a primitive kind of alarm clock. For instance, say you need to get up at 7am on the 4th of September 2015, but for some reason your usual alarm clock is broken and you only have your laptop. You can specify the time to get up (being careful about time zones, since `DateTime.new` uses UTC by default) as an [`Instant`](/type/Instant) and pass this to `sleep-until`, after which you can play an mp3 file to wake you up instead of your normal alarm clock. This scenario looks roughly like this:

```raku
# DateTime.new uses UTC by default, so get time zone from current time
my $timezone = DateTime.now.timezone;
my $instant = DateTime.new(
    year => 2015,
    month => 9,
    day => 4,
    hour => 7,
    minute => 0,
    timezone => $timezone
).Instant;
sleep-until $instant;
qqx{mplayer wake-me-up.mp3};

```

## [sub infix:<->](#class_Date "go to top of document")[§](#sub_infix:<-> "direct link")

```raku
multi infix:<-> (Date:D, Int:D --> Date:D)
multi infix:<-> (Date:D, Date:D --> Int:D)
```

Takes a date to subtract from and either an [`Int`](/type/Int), representing the number of days to subtract, or another `Date` object. Returns a new `Date` object or the number of days between the two dates, respectively.

```raku
say Date.new('2016-12-25') - Date.new('2016-12-24'); # OUTPUT: «1␤»
say Date.new('2015-12-25') - Date.new('2016-11-21'); # OUTPUT: «-332␤»
say Date.new('2016-11-21') - 332;                    # OUTPUT: «2015-12-25␤»
```

## [sub infix:<+>](#class_Date "go to top of document")[§](#sub_infix:<+> "direct link")

```raku
multi infix:<+> (Date:D, Int:D --> Date:D)
multi infix:<+> (Int:D, Date:D --> Date:D)
```

Takes an [`Int`](/type/Int) and adds that many days to the given `Date` object.

```raku
say Date.new('2015-12-25') + 332; # OUTPUT: «2016-11-21␤»
say 1 + Date.new('2015-12-25');   # OUTPUT: «2015-12-26␤»
```

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

Type relations for `Date`

raku-type-graph

Date
Date

Any
Any

Date->Any

Dateish
Dateish

Date->Dateish

Mu
Mu

Any->Mu

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


## dist_github-Xliff-Audio-OggVorbis.md
# Audio::OggVorbis

Perl 6 Bindings for libogg, libvorbis, and libvorbisenc.

This module depends on native libraries. You can insure that these are
properly installed on Debian environments by using the following command:

```
sudo apt-get install -y libogg-dev libvorbis-dev

```

Right now, this library only consists of library bindings, however subsequent
releases will include a Perlish API.

Special thanks go to #perl6 on freenode. Their contributions got me this far.


## dist_zef-massa-Config-Parser-NetRC.md
[![Actions Status](https://github.com/massa/Config-Parser-NetRC/actions/workflows/test.yml/badge.svg)](https://github.com/massa/Config-Parser-NetRC/actions)

# NAME

Config::Parser::NetRC - A NetRC parser for [Config](https://github.com/scriptkitties/p6-Config)

# SYNOPSIS

```
use Config;

my Config $c .= new {}, :name<config>;
$c.=read('', Config::Parser::NetRC); # read from default "~/.netrc" file

```

# DESCRIPTION

Config::Parser::NetRC is a simple NetRC parser for NetRC-style files

# AUTHOR

Humberto Massa [humbertomassa@gmail.com](mailto:humbertomassa@gmail.com)

# INSTALLATION

```
$ zef install Config::Parser::NetRC

```

# COPYRIGHT AND LICENSE

Copyright 2024 Humberto Massa

This library is free software; you can redistribute it and/or modify it under either the Artistic License 2.0 or the LGPL v3.0, at your convenience.